-
Notifications
You must be signed in to change notification settings - Fork 2
followee_favorites and followee_reposts match v1 api. #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,33 +65,50 @@ SELECT | |
| is_scheduled_release, | ||
| is_unlisted, | ||
|
|
||
| ARRAY( | ||
| SELECT user_id | ||
| FROM saves | ||
| JOIN follows ON followee_user_id = saves.user_id AND follower_user_id = @my_id | ||
| JOIN aggregate_user USING (user_id) | ||
| -- todo: join users, filter out deactivated | ||
| WHERE @my_id > 0 | ||
| AND save_item_id = t.track_id | ||
| AND save_type = 'track' | ||
| AND saves.is_delete = false | ||
| ORDER BY follower_count DESC | ||
| LIMIT 10 | ||
| )::int[] as followee_favorite_ids, | ||
| ( | ||
| SELECT json_agg( | ||
| json_build_object( | ||
| 'user_id', r.user_id::text, | ||
| 'repost_item_id', repost_item_id::text, -- this is redundant | ||
| 'repost_type', 'RepostType.track', -- some sqlalchemy bs | ||
| 'created_at', r.created_at -- this is not actually present in python response? | ||
| ) | ||
| ) | ||
| 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 | ||
| JOIN aggregate_user USING (user_id) | ||
| WHERE repost_item_id = t.track_id | ||
| AND repost_type = 'track' | ||
| AND reposts.is_delete = false | ||
| ORDER BY follower_count DESC | ||
| LIMIT 3 | ||
| ) r | ||
| )::jsonb as followee_reposts, | ||
|
|
||
| ( | ||
| SELECT json_agg( | ||
| json_build_object( | ||
| 'user_id', r.user_id::text, | ||
| 'favorite_item_id', r.save_item_id::text, -- this is redundant | ||
| 'favorite_type', 'SaveType.track', -- some sqlalchemy bs | ||
| 'created_at', r.created_at -- this is not actually present in python response? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting.. maybe it gets marshalled away? |
||
| ) | ||
| ) | ||
| 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 | ||
| JOIN aggregate_user USING (user_id) | ||
| WHERE save_item_id = t.track_id | ||
| AND save_type = 'track' | ||
| AND saves.is_delete = false | ||
| ORDER BY follower_count DESC | ||
| LIMIT 3 | ||
| ) r | ||
| )::jsonb as followee_favorites, | ||
|
|
||
| ARRAY( | ||
| SELECT user_id | ||
| FROM reposts | ||
| JOIN follows ON followee_user_id = reposts.user_id AND follower_user_id = @my_id | ||
| JOIN aggregate_user USING (user_id) | ||
| -- todo: join users, filter out deactivated | ||
| WHERE @my_id > 0 | ||
| AND repost_item_id = t.track_id | ||
| AND repost_type = 'track' | ||
| AND reposts.is_delete = false | ||
| ORDER BY follower_count DESC | ||
| LIMIT 10 | ||
| )::int[] as followee_repost_ids, | ||
|
|
||
| -- followee_favorites, | ||
| -- route_id, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love these comments LOOOL