This commit is contained in:
1 parent
48e89f85e4
commit
dad2e768c1
2 files changed
+18
-6
No files matched your search
@@ -71,20 +71,28 @@ def _load_json(value, fallback):
|
||||
|
||||
def _game_tags(con):
|
||||
tags = {}
|
||||
tags_ru = {}
|
||||
for row in con.execute("""
|
||||
SELECT gt.appid, tn.name
|
||||
SELECT gt.appid, tn.name, COALESCE(tn.name_ru, '') AS name_ru
|
||||
FROM game_tags gt JOIN tag_names tn ON tn.tag_id = gt.tag_id
|
||||
ORDER BY gt.appid, tn.name
|
||||
"""):
|
||||
tags.setdefault(row["appid"], []).append(row["name"])
|
||||
return tags
|
||||
tags_ru.setdefault(row["appid"], []).append(row["name_ru"] or "")
|
||||
return tags, tags_ru
|
||||
|
||||
|
||||
def _game_genres(con):
|
||||
genres = {}
|
||||
for row in con.execute("SELECT appid, genre FROM game_genres ORDER BY appid, genre"):
|
||||
genres_ru = {}
|
||||
for row in con.execute("""
|
||||
SELECT gg.appid, gg.genre, COALESCE(gn.name_ru, '') AS name_ru
|
||||
FROM game_genres gg LEFT JOIN genre_names gn ON gn.name = gg.genre
|
||||
ORDER BY gg.appid, gg.genre
|
||||
"""):
|
||||
genres.setdefault(row["appid"], []).append(row["genre"])
|
||||
return genres
|
||||
genres_ru.setdefault(row["appid"], []).append(row["name_ru"] or "")
|
||||
return genres, genres_ru
|
||||
|
||||
|
||||
def _details_map(con):
|
||||
@@ -104,8 +112,8 @@ def collect(con, handle=None, steamid=None, notes=True, translations=True,
|
||||
row = con.execute("SELECT value FROM schema_meta WHERE key = 'steamid'").fetchone()
|
||||
steamid = (steamid or (row[0] if row else "") or "").strip()
|
||||
|
||||
tags = _game_tags(con)
|
||||
genres = _game_genres(con)
|
||||
tags, tags_ru = _game_tags(con)
|
||||
genres, genres_ru = _game_genres(con)
|
||||
details = _details_map(con)
|
||||
translations = _translations_map(con) if translations else {}
|
||||
|
||||
@@ -126,6 +134,8 @@ def collect(con, handle=None, steamid=None, notes=True, translations=True,
|
||||
"parent_appid": game["parent_appid"],
|
||||
"genres": genres.get(appid, []),
|
||||
"tags": tags.get(appid, []),
|
||||
"genres_ru": genres_ru.get(appid, []),
|
||||
"tags_ru": tags_ru.get(appid, []),
|
||||
}
|
||||
detail = details.get(appid)
|
||||
if detail:
|
||||
|
||||
Reference in new issue
Block a user