Skip to content

Conversation

@stereosteve
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@stereosteve stereosteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work Steve!

// todo: fill this out
// hide these GetTrackRow fields
FolloweeFavoriteIds any `json:"followee_favorite_ids,omitempty"`
FolloweeRepostIds any `json:"followee_repost_ids,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_tracks.sql adds these fields with list of user IDs. Here we hide them by shadowing the fields from the embedded GetTrackRow struct and making them omitempty.

}
for _, id := range track.FolloweeRepostIds {
userIds = append(userIds, id)
}
Copy link
Contributor Author

@stereosteve stereosteve Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this list of users IDs (owner, known reposters, know savers) across all tracks can have duplicates... but we're passing it into sql land with where user_id = ANY(@ids) type of thing... sql does set stuff and so we incur near zero cost for duplicates.

This is why I skip de-dupe on this list and other similar id lists used in a set based context.

AND saves.is_delete = false
ORDER BY follower_count DESC
LIMIT 10
)::int[] as followee_favorite_ids,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

::int[] helps sqlc choose []int32 for generated struct (instead of interface{} aka any)

@stereosteve stereosteve merged commit 0a41ed0 into main Apr 8, 2025
2 checks passed
@stereosteve stereosteve deleted the followee_reposts branch April 14, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants