Skip to content

Commit 6bbd182

Browse files
committed
Fix timestamps on DatabaseActivityPage preventing pagination
1 parent a441964 commit 6bbd182

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

Refresh.Database/Models/Activity/DatabaseActivityGroup.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,17 @@ internal void Cleanup()
2020

2121
this.UserChildren = null;
2222
}
23+
24+
public void TraverseChildrenForEventsRecursively(Action<Event> callback)
25+
{
26+
foreach (Event @event in this.Events)
27+
{
28+
callback(@event);
29+
}
30+
31+
foreach (DatabaseActivityGroup group in this.Children)
32+
{
33+
group.TraverseChildrenForEventsRecursively(callback);
34+
}
35+
}
2336
}

Refresh.Database/Models/Activity/DatabaseActivityPage.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,24 @@ internal DatabaseActivityPage(GameDatabaseContext database, IReadOnlyCollection<
1515
this.GenerateGroups(events);
1616

1717
this.Cleanup();
18-
19-
if (this.EventGroups.Count > 0)
18+
19+
this.Start = DateTimeOffset.MaxValue;
20+
this.End = DateTimeOffset.MinValue;
21+
foreach (DatabaseActivityGroup group in this.EventGroups)
2022
{
21-
this.Start = DateTimeOffset.FromUnixTimeMilliseconds(parameters.Timestamp);
22-
this.End = DateTimeOffset.FromUnixTimeMilliseconds(parameters.EndTimestamp);
23+
group.TraverseChildrenForEventsRecursively((e) =>
24+
{
25+
if (e.Timestamp > this.End)
26+
this.End = e.Timestamp;
27+
28+
if (e.Timestamp < this.Start)
29+
this.Start = e.Timestamp;
30+
});
2331
}
32+
33+
// go back 1 week by default to look for next page
34+
if(this.End != DateTimeOffset.MinValue)
35+
this.End = this.End.Subtract(TimeSpan.FromDays(7));
2436
}
2537

2638
public DateTimeOffset Start;

0 commit comments

Comments
 (0)