-
Notifications
You must be signed in to change notification settings - Fork 1
[API-95] Add resolve endpoint, improve permalink matching #55
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| -- name: GetPlaylistIdsByPermalink :many | ||
| WITH lower_handles AS ( | ||
| SELECT LOWER(h) AS handle | ||
| FROM unnest(@handles::text[]) AS h | ||
| ), | ||
| lower_permalinks AS ( | ||
| SELECT LOWER(p) AS permalink | ||
| FROM unnest(@permalinks::text[]) AS p | ||
| ) | ||
| SELECT pr.playlist_id | ||
| FROM playlist_routes pr | ||
| JOIN users u ON u.user_id = pr.owner_id | ||
| JOIN lower_handles lh | ||
| ON u.handle_lc = lh.handle | ||
| WHERE pr.slug = ANY(@slugs::text[]) | ||
| -- in case of conflicts across users | ||
| AND ( | ||
| CONCAT('/', u.handle_lc, '/playlist/', LOWER(pr.slug)) = ANY( | ||
| SELECT permalink FROM lower_permalinks | ||
| ) | ||
| OR CONCAT('/', u.handle_lc, '/album/', LOWER(pr.slug)) = ANY( | ||
| SELECT permalink FROM lower_permalinks | ||
| ) | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,19 @@ | ||
| -- name: GetTrackIdsByPermalink :many | ||
| SELECT track_id | ||
| FROM track_routes | ||
| JOIN users ON users.user_id = track_routes.owner_id | ||
| WHERE handle_lc = ANY(@handles::text[]) | ||
| AND slug = ANY(@slugs::text[]) | ||
| AND CONCAT(handle_lc, '/', slug) = ANY(@permalinks::text[]) -- in case of conflicts across users | ||
| ; | ||
| WITH lower_handles AS ( | ||
| SELECT LOWER(h) AS handle | ||
| FROM unnest(@handles::text[]) AS h | ||
| ), | ||
| lower_permalinks AS ( | ||
| SELECT LOWER(p) AS permalink | ||
| FROM unnest(@permalinks::text[]) AS p | ||
| ) | ||
| SELECT tr.track_id | ||
| FROM track_routes tr | ||
| JOIN users u ON u.user_id = tr.owner_id | ||
| JOIN lower_handles lh | ||
| ON u.handle_lc = lh.handle | ||
| WHERE tr.slug = ANY(@slugs::text[]) | ||
| -- in case of conflicts across usAers | ||
| AND CONCAT('/', u.handle_lc, '/', LOWER(tr.slug)) = ANY( | ||
| SELECT permalink FROM lower_permalinks | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| -- name: GetUserForHandle :one | ||
| SELECT user_id FROM users | ||
| WHERE | ||
| handle_lc = lower(@handle) | ||
| ORDER BY created_at ASC | ||
| LIMIT 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| slug,title_slug,collision_id,owner_id,playlist_id | ||
| playlist-by-permalink,playlist-by-permalink,0,7,500 | ||
| album-by-permalink,album-by-permalink,0,8,501 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| "slug","title_slug","collision_id","owner_id","track_id","is_current","blockhash","blocknumber","txhash" | ||
| "track-by-permalink","track-by-permalink",0,6,500,TRUE,"0x24f1465e4bd8803b79b2cbcfad695363a640623053563ffd20fdeaf4656a7b89",23200013,"0x76dcea2bf98e56f683b95a071f5c87405a864eea87243920e60cbc7b96ad565b" | ||
| slug,title_slug,collision_id,owner_id,track_id | ||
| track-by-permalink,track-by-permalink,0,6,500 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
we should actually
if err != nil {return err}here. My bad on that.This should return
pgx.ErrNoRowsif not found I believe.So returning on error avoids setting
no_exist_handle = 0in the cache... which would be bad if the indexer is behind and it might work on next try.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.
yeah great catch