Skip to content

Commit f923b60

Browse files
committed
Sort subjects and photos with user
1 parent f5bdf00 commit f923b60

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Refresh.Database/GameDatabaseContext.Photos.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public partial class GameDatabaseContext // Photos
2020
.Include(p => p.Level)
2121
.Include(p => p.Level!.Publisher)
2222
.Include(p => p.Level!.Publisher!.Statistics)
23-
.Include(p => p.Subjects);
23+
.Include(p => p.Subjects.OrderBy(s => s.PlayerId));
2424

2525
private IQueryable<GamePhotoSubject> GamePhotoSubjectsIncluded => this.GamePhotoSubjects
2626
.Include(p => p.User)
@@ -34,7 +34,7 @@ public partial class GameDatabaseContext // Photos
3434
.Include(p => p.Photo!.LargeAsset)
3535
.Include(p => p.Photo!.MediumAsset)
3636
.Include(p => p.Photo!.SmallAsset)
37-
.Include(p => p.Photo!.Subjects);
37+
.Include(p => p.Photo!.Subjects.OrderBy(s => s.PlayerId));
3838

3939
public GamePhoto UploadPhoto(IPhotoUpload photo, IEnumerable<IPhotoUploadSubject> subjects, GameUser publisher, GameLevel? level)
4040
{
@@ -221,11 +221,14 @@ public void RemovePhoto(GamePhoto photo)
221221
}
222222

223223
public IQueryable<GamePhotoSubject> GetSubjectsInPhoto(GamePhoto photo)
224-
=> this.GamePhotoSubjectsIncluded.Where(s => s.PhotoId == photo.PhotoId);
224+
=> this.GamePhotoSubjectsIncluded
225+
.Where(s => s.PhotoId == photo.PhotoId)
226+
.OrderBy(s => s.PlayerId);
225227

226228
public IQueryable<GameUser> GetUsersInPhoto(GamePhoto photo)
227229
=> this.GetSubjectsInPhoto(photo)
228230
.Where(s => s.User != null)
231+
.OrderBy(s => s.PlayerId)
229232
.Select(s => s.User!);
230233

231234
public int GetTotalPhotoCount() => this.GamePhotos.Count();
@@ -253,7 +256,8 @@ public int GetTotalPhotosByUser(GameUser user)
253256
public DatabaseList<GamePhoto> GetPhotosWithUser(GameUser user, int count, int skip) =>
254257
new(this.GamePhotoSubjectsIncluded
255258
.Where(s => s.UserId == user.UserId)
256-
.Select(s => s.Photo), skip, count);
259+
.Select(s => s.Photo)
260+
.OrderByDescending(p => p.TakenAt), skip, count);
257261

258262
[Pure]
259263
public int GetTotalPhotosWithUser(GameUser user)

0 commit comments

Comments
 (0)