-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3087 from metabrainz/ansh/add-yim-genre-graph
Add Genre Graph for YIM 2024
- Loading branch information
Showing
6 changed files
with
230 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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,26 @@ | ||
from psycopg2.extras import DictCursor | ||
|
||
|
||
def load_genre_with_subgenres(mb_curs: DictCursor): | ||
query = """ | ||
SELECT | ||
g1.name as genre, | ||
g1.gid::text as genre_gid, | ||
g2.name as subgenre, | ||
g2.gid::text as subgenre_gid | ||
FROM genre g1 | ||
LEFT JOIN ( | ||
SELECT entity0, entity1 | ||
FROM l_genre_genre lgg | ||
WHERE lgg.link IN ( | ||
SELECT id | ||
FROM link | ||
WHERE link_type = 1095 | ||
) | ||
) lgg ON g1.id = lgg.entity0 | ||
LEFT JOIN genre g2 ON lgg.entity1 = g2.id | ||
ORDER BY g1.name, COALESCE(g2.name, ''); | ||
""" | ||
|
||
mb_curs.execute(query) | ||
return mb_curs.fetchall() |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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