Skip to content

Commit

Permalink
update user notification query
Browse files Browse the repository at this point in the history
  • Loading branch information
jxsl13 committed Jan 22, 2024
1 parent c3adbdb commit c6bc17c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions queries/player_count_notification_messages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ SELECT
COALESCE(pcm.message_id, 0)::bigint AS prev_message_id,
pcn.user_id,
MAX(COALESCE(np.num_players, 0))::smallint AS num_players
FROM tracking t
FROM channels c
JOIN tracking t ON c.channel_id = t.channel_id
LEFT JOIN (
SELECT ac.address, count(*) AS num_players
FROM active_server_clients ac
GROUP BY ac.address
ORDER BY ac.address
ORDER BY ac.address
) np ON np.address = t.address
JOIN player_count_notifications pcn
ON (
Expand All @@ -23,6 +24,7 @@ ON (
)
LEFT JOIN player_count_notification_messages pcm
ON (t.channel_id = pcm.channel_id)
WHERE c.running = TRUE
GROUP BY t.guild_id, t.channel_id, pcm.message_id, pcn.user_id, num_players
ORDER BY t.guild_id, t.channel_id, pcm.message_id, num_players, pcn.user_id;

Expand Down
6 changes: 4 additions & 2 deletions sqlc/player_count_notification_messages.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6bc17c

Please sign in to comment.