Fix favouritePlaylists logic

This commit is contained in:
Slendy 2022-09-24 21:34:05 -05:00
parent a15ff2c886
commit 2217c20803
No known key found for this signature in database
GPG key ID: 7288D68361B91428

View file

@ -210,10 +210,8 @@ public class ListController : ControllerBase
int targetUserId = await this.database.Users.Where(u => u.Username == username).Select(u => u.UserId).FirstOrDefaultAsync(); int targetUserId = await this.database.Users.Where(u => u.Username == username).Select(u => u.UserId).FirstOrDefaultAsync();
if (targetUserId == 0) return this.StatusCode(403, ""); if (targetUserId == 0) return this.StatusCode(403, "");
IEnumerable<Playlist> heartedPlaylists = this.database.Playlists.Include(p => p.Creator).Where(p => p.CreatorId == targetUserId) IEnumerable<Playlist> heartedPlaylists = this.database.HeartedPlaylists.Where(p => p.UserId == targetUserId)
.Skip(Math.Max(0, pageStart - 1)) .Include(p => p.Playlist).Include(p => p.Playlist.Creator).OrderByDescending(p => p.HeartedPlaylistId).Select(p => p.Playlist);
.Take(Math.Min(pageSize, 30))
.AsEnumerable();
string response = heartedPlaylists.Aggregate(string.Empty, (current, p) => current + p.Serialize()); string response = heartedPlaylists.Aggregate(string.Empty, (current, p) => current + p.Serialize());