Skip to content
Snippets Groups Projects
Commit e026c13e authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Fix: Latest Activity ignoring today

parent 3e7b2ffd
No related branches found
No related tags found
1 merge request!19Fix: Correct last activity date
Pipeline #864274 passed
......@@ -274,11 +274,14 @@ public class UserReporting : Reporting<UserReportingOptions>
private DateTime? GetLatestActivity(Guid id)
{
/*
* TODO: Query may take ages to execute and can lead to timeouts. Make sure to create an index!
* CREATE INDEX log_idx_userid_loglevel_servertime ON Coscine.dbo.Log (UserId, LogLevel, ServerTimestamp);
*/
var latestLog = _logModel.GetAllWhere(l => l.LogLevel.Equals("Analytics") && l.UserId.Equals(id)).OrderByDescending(a => a.ServerTimestamp).FirstOrDefault();
var today = DateTime.Today;
var latestLog = _logModel
.GetAllWhere(l =>
l.LogLevel.Equals("Analytics")
&& l.UserId.Equals(id)
&& l.ServerTimestamp < today)
.OrderByDescending(a => a.ServerTimestamp)
.FirstOrDefault();
if (latestLog is not null)
{
return latestLog.ServerTimestamp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment