Skip to content

Commit

Permalink
always show yourself in whoknowsgenre
Browse files Browse the repository at this point in the history
  • Loading branch information
th0mk committed Apr 16, 2024
1 parent f3f01d6 commit 9edf188
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/FMBot.Bot/Services/GenreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,21 @@ public async Task<IEnumerable<UserArtist>> GetTopUserArtistsForGuildAsync(int gu

public async Task<IEnumerable<UserArtist>> GetTopUserArtistsForUserFriendsAsync(int userId, string genreName)
{
const string sql = "SELECT " +
"ua.user_id, " +
"LOWER(ua.name) AS name, " +
"ua.playcount " +
const string sql = "SELECT ua.user_id, LOWER(ua.name) AS name, ua.playcount " +
"FROM user_artists AS ua " +
"INNER JOIN users AS u ON ua.user_id = u.user_id " +
"INNER JOIN friends AS fr ON fr.friend_user_id = ua.user_id " +
"WHERE fr.user_id = @userId " +
"AND LOWER(ua.name) = ANY(SELECT LOWER(artists.name) AS artist_name " +
"FROM public.artist_genres AS ag " +
"INNER JOIN artists ON artists.id = ag.artist_id WHERE LOWER(ag.name) = LOWER(CAST(@genreName AS CITEXT))) ";
"INNER JOIN artists ON artists.id = ag.artist_id WHERE LOWER(ag.name) = LOWER(CAST(@genreName AS CITEXT))) " +
"UNION " +
"SELECT ua.user_id, LOWER(ua.name) AS name, ua.playcount " +
"FROM user_artists AS ua " +
"WHERE ua.user_id = @userId " +
"AND LOWER(ua.name) = ANY(SELECT LOWER(artists.name) AS artist_name " +
"FROM public.artist_genres AS ag " +
"INNER JOIN artists ON artists.id = ag.artist_id WHERE LOWER(ag.name) = LOWER(CAST(@genreName AS CITEXT))) ";

DefaultTypeMap.MatchNamesWithUnderscores = true;
await using var connection = new NpgsqlConnection(this._botSettings.Database.ConnectionString);
Expand Down

0 comments on commit 9edf188

Please sign in to comment.