Skip to content

Conversation

@stereosteve
Copy link
Contributor

@stereosteve stereosteve commented Apr 8, 2025

support url like:

/v1/full/users/handle/stereosteve/tracks?filter_tracks=all&limit=10&offset=0&sort=date&user_id=7eP5n

Some notes:

  • sqlc doesn't have good support for sort args.
  • so we use pgx to get a list of track ids and use the sqlc get_tracks query to get them in that order.
  • pgx also doesn't support parameterized sort args since db doesn't support these in prepared statements in first place. ORM and sqlbuilders just escape and build sql, kind of like what I've done here.

My thoughts:

  • I think this is mostly okay. I think the nice thing here is that FullTracks handles the logic of building up result, so it's okay if the only interface is get-by-id style. Elemental used postgres.js which has better support for optional subqueries... but in general it followed similar patterns.
  • might want to use a sql builder atop of pgx to build the "ID list" query (pre-sqlc)
  • probably all the visibility rules should be in the "ID List" query... and get-by-id does no filtering.
  • sql builder might help with having a "base query" that captures visibility rules, including things like is_unlisted = false OR owner_id = @myId type of thing.

Anyway I think this is okay to merge as is... just thinking about some of the patterns and constraints here lmk if any thoughts.

@raymondjacobson raymondjacobson merged commit 094907e into main Apr 8, 2025
2 checks passed
@stereosteve stereosteve deleted the v1_user_handle_tracks 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.

4 participants