diff options
| -rw-r--r-- | src/DevHive.Data/Repositories/FeedRepository.cs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/DevHive.Data/Repositories/FeedRepository.cs b/src/DevHive.Data/Repositories/FeedRepository.cs index 7ab9a91..d8170d0 100644 --- a/src/DevHive.Data/Repositories/FeedRepository.cs +++ b/src/DevHive.Data/Repositories/FeedRepository.cs @@ -25,11 +25,14 @@ namespace DevHive.Data.Repositories List<Post> posts = await this._context.Posts .Where(post => post.TimeCreated < firstRequestIssued) .Where(p => friendsIds.Contains(p.Creator.Id)) - .OrderByDescending(x => x.TimeCreated) .Skip((pageNumber - 1) * pageSize) .Take(pageSize) .ToListAsync(); + // Ordering by descending can't happen in query, because it doesn't order it + // completely correctly (example: in query these two times are ordered + // like this: 2021-01-30T11:49:45, 2021-01-28T21:37:40.701244) + posts = posts.OrderByDescending(x => x.TimeCreated.ToFileTime()).ToList(); return posts; } @@ -38,11 +41,12 @@ namespace DevHive.Data.Repositories List<Post> posts = await this._context.Posts .Where(post => post.TimeCreated < firstRequestIssued) .Where(p => p.Creator.Id == user.Id) - .OrderByDescending(x => x.TimeCreated) .Skip((pageNumber - 1) * pageSize) .Take(pageSize) .ToListAsync(); + // Look at GetFriendsPosts on why this is done like this + posts = posts.OrderByDescending(x => x.TimeCreated.ToFileTime()).ToList(); return posts; } } |
