diff --git a/query_discord_music.py b/query_discord_music.py new file mode 100644 index 00000000..aa3cf10a --- /dev/null +++ b/query_discord_music.py @@ -0,0 +1,120 @@ +all_query = """SELECT + discord.royal_id, + discord.discord_id, + discord.name, + discord.discriminator, + discord.avatar_hex, + fav_songs.fav_song, + fav_songs.max_plays, + last_songs.last_song, + last_songs.last_play_time +FROM discord +LEFT JOIN ( + SELECT DISTINCT ON (ma.discord_id) + ma.discord_id discord_id, + fs.fav_song fav_song, + ma.max_plays max_plays + FROM ( + SELECT + discord_id, + max(plays) max_plays + FROM + ( + SELECT + playedmusic.enqueuer_id discord_id, + playedmusic.filename fav_song, + count(*) plays + FROM playedmusic + GROUP BY playedmusic.filename, playedmusic.enqueuer_id + ORDER BY plays DESC + ) play_counts + GROUP BY discord_id + ) ma + INNER JOIN + ( + SELECT + playedmusic.enqueuer_id discord_id, + playedmusic.filename fav_song, + count(*) plays + FROM playedmusic + GROUP BY playedmusic.filename, playedmusic.enqueuer_id + ORDER BY plays DESC + ) fs ON fs.discord_id = ma.discord_id AND fs.plays = ma.max_plays +) fav_songs ON fav_songs.discord_id = discord.discord_id +LEFT JOIN +( + SELECT DISTINCT ON (playedmusic.enqueuer_id) + playedmusic.enqueuer_id discord_id, + playedmusic.filename last_song, + last_play_times.last_play_time + FROM playedmusic + JOIN ( + SELECT + playedmusic.enqueuer_id discord_id, + max(playedmusic.timestamp) last_play_time + FROM playedmusic + GROUP BY playedmusic.enqueuer_id + ) last_play_times ON playedmusic.timestamp = last_play_times.last_play_time +) last_songs ON last_songs.discord_id = discord.discord_id;""" + + +# TODO: can and should be optimized, but I'm too lazy for that +one_query = """SELECT + discord.royal_id, + discord.discord_id, + discord.name, + discord.discriminator, + discord.avatar_hex, + fav_songs.fav_song, + fav_songs.max_plays, + last_songs.last_song, + last_songs.last_play_time +FROM discord +LEFT JOIN ( + SELECT DISTINCT ON (ma.discord_id) + ma.discord_id discord_id, + fs.fav_song fav_song, + ma.max_plays max_plays + FROM ( + SELECT + discord_id, + max(plays) max_plays + FROM + ( + SELECT + playedmusic.enqueuer_id discord_id, + playedmusic.filename fav_song, + count(*) plays + FROM playedmusic + GROUP BY playedmusic.filename, playedmusic.enqueuer_id + ORDER BY plays DESC + ) play_counts + GROUP BY discord_id + ) ma + INNER JOIN + ( + SELECT + playedmusic.enqueuer_id discord_id, + playedmusic.filename fav_song, + count(*) plays + FROM playedmusic + GROUP BY playedmusic.filename, playedmusic.enqueuer_id + ORDER BY plays DESC + ) fs ON fs.discord_id = ma.discord_id AND fs.plays = ma.max_plays +) fav_songs ON fav_songs.discord_id = discord.discord_id +LEFT JOIN +( + SELECT DISTINCT ON (playedmusic.enqueuer_id) + playedmusic.enqueuer_id discord_id, + playedmusic.filename last_song, + last_play_times.last_play_time + FROM playedmusic + JOIN ( + SELECT + playedmusic.enqueuer_id discord_id, + max(playedmusic.timestamp) last_play_time + FROM playedmusic + GROUP BY playedmusic.enqueuer_id + ) last_play_times ON playedmusic.timestamp = last_play_times.last_play_time +) last_songs ON last_songs.discord_id = discord.discord_id +WHERE discord.royal_id = ?;""" \ No newline at end of file diff --git a/static/nryg.less b/static/nryg.less index 71aba555..59c1d29e 100644 --- a/static/nryg.less +++ b/static/nryg.less @@ -205,6 +205,11 @@ nav { grid-row: 3; } + .game-extra { + grid-row: 4; + font-size: smaller; + } + .player { grid-row: 1; font-size: large; @@ -614,6 +619,7 @@ nav { padding: 18px; color: white; font-family: "Whitney", sans-serif; + grid-template-columns: 50% 50%; a, a:hover, a:active, a:visited { color: white; @@ -623,6 +629,10 @@ nav { border-radius: 16px; } + .game-score { + overflow: hidden; + } + .last-video { grid-column: 1 } @@ -632,7 +642,7 @@ nav { } .none { - opacity: 0.3; + color: rgba(255, 255, 255, 0.3); } } diff --git a/templates/minis/discord.html b/templates/minis/discord.html index f40339c8..5d13b2e9 100644 --- a/templates/minis/discord.html +++ b/templates/minis/discord.html @@ -7,26 +7,32 @@