Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions api/dbv1/get_tracks.sql.go

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

18 changes: 14 additions & 4 deletions api/dbv1/queries/get_tracks.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
-- name: GetTracks :many
WITH my_follows AS (
SELECT
followee_user_id as user_id,
follower_count
FROM follows
JOIN aggregate_user ON followee_user_id = user_id
WHERE @my_id > 0
AND follower_user_id = @my_id
AND follows.is_delete = false
ORDER BY follower_count DESC
LIMIT 5000
)
SELECT
t.track_id,
description,
Expand Down Expand Up @@ -98,8 +110,7 @@ SELECT
FROM (
SELECT user_id, repost_item_id, reposts.created_at
FROM reposts
JOIN follows ON followee_user_id = reposts.user_id AND follower_user_id = @my_id AND follows.is_delete = false
JOIN aggregate_user USING (user_id)
JOIN my_follows USING (user_id)
WHERE repost_item_id = t.track_id
AND repost_type = 'track'
AND reposts.is_delete = false
Expand All @@ -120,8 +131,7 @@ SELECT
FROM (
SELECT user_id, save_item_id, saves.created_at
FROM saves
JOIN follows ON followee_user_id = saves.user_id AND follower_user_id = @my_id AND follows.is_delete = false
JOIN aggregate_user USING (user_id)
JOIN my_follows USING (user_id)
WHERE save_item_id = t.track_id
AND save_type = 'track'
AND saves.is_delete = false
Expand Down
Loading