Skip to content

Commit

Permalink
Compensate for timestamp rounding issues on MS SQL (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBunTes authored Apr 5, 2024
1 parent 37790ec commit be385a1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Core/Services/MastodonService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class MastodonService : IMastodonService
private const string FeedHashtag = "h5yr";
private const string FeedCacheKey = "mastodonposts";
private const int FeedCacheMinutes = 15;
private const string EmojiCacheKey = "mastodonemojis";


public MastodonService(ILogger<MastodonService> logger, AppCaches appCaches, IPostCounterStore postCounterStore)
Expand Down Expand Up @@ -111,7 +110,7 @@ private void UpdatePostCount(List<MastodonStatus> latestPosts)
_postCounterStore.Save(postCounter);
}

var newerPosts = latestPosts.Where(p => p.CreatedAt.DateTimeOffset.DateTime > postCounter.Date);
var newerPosts = latestPosts.Where(p => p.CreatedAt.DateTimeOffset.DateTime > postCounter.Date.AddMilliseconds(3)); // 3ms covers for SQL datetime rounding
if (newerPosts.Any())
{
// We have newer posts, so update the count
Expand Down

0 comments on commit be385a1

Please sign in to comment.