fixed profile meta and game columns
This commit is contained in:
parent
46ff94e62a
commit
6f03007b11
|
|
@ -4,6 +4,7 @@
|
|||
BEGIN;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS data.profile_meta (
|
||||
name TEXT,
|
||||
steam64_id TEXT,
|
||||
is_collector BOOL,
|
||||
is_leetify_staff BOOL,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
BEGIN;
|
||||
|
||||
SELECT steam64_id, is_collector, is_leetify_staff, is_pro_plan,
|
||||
SELECT name, steam64_id, is_collector, is_leetify_staff, is_pro_plan,
|
||||
leetify_user_id, faceit_nickname
|
||||
FROM data.profile_meta
|
||||
WHERE FALSE;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ def extract_profile_meta(id, api=Leetify(), conn=None):
|
|||
if not conn:
|
||||
conn = connect()
|
||||
|
||||
cols = [
|
||||
cols_api = [
|
||||
"name",
|
||||
"steam64Id",
|
||||
"isCollector",
|
||||
|
|
@ -57,14 +57,24 @@ def extract_profile_meta(id, api=Leetify(), conn=None):
|
|||
"leetifyUserId",
|
||||
"faceitNickname",
|
||||
]
|
||||
cols_db = [
|
||||
"name",
|
||||
"steam64_id",
|
||||
"is_collector",
|
||||
"is_leetify_staff",
|
||||
"is_pro_plan",
|
||||
"leetify_user_id",
|
||||
"faceit_nickname",
|
||||
]
|
||||
|
||||
profile = api.get_profile(id)
|
||||
meta = meta_from_profile(profile)
|
||||
vals = vals_in_order(meta, cols)
|
||||
vals = vals_in_order(meta, cols_api)
|
||||
|
||||
with conn.cursor() as curs:
|
||||
sql = f"""
|
||||
INSERT INTO data.profile_meta ({', '.join(cols)})
|
||||
VALUES ({', '.join(['%s'] * len(vals))});
|
||||
INSERT INTO data.profile_meta ({', '.join(cols_db)})
|
||||
VALUES ({', '.join(['%s'] * len(cols_db))});
|
||||
"""
|
||||
curs.execute(sql, vals)
|
||||
conn.commit()
|
||||
|
|
@ -74,7 +84,7 @@ def extract_profile_games(profile, conn=None):
|
|||
if not conn:
|
||||
conn = connect()
|
||||
|
||||
cols = [
|
||||
cols_api = [
|
||||
"leetifyUserId",
|
||||
"ctLeetifyRating",
|
||||
"ctLeetifyRatingRounds",
|
||||
|
|
@ -95,14 +105,35 @@ def extract_profile_games(profile, conn=None):
|
|||
"partySize",
|
||||
]
|
||||
|
||||
cols_db = [
|
||||
"leetify_user_id",
|
||||
"ct_Leetify_rating",
|
||||
"ct_Leetify_rating_rounds",
|
||||
"data_source",
|
||||
"elo",
|
||||
"game_finished_at",
|
||||
"game_id",
|
||||
"is_cs2",
|
||||
"map_name",
|
||||
"match_result",
|
||||
"scores",
|
||||
"skill_level",
|
||||
"t_leetify_rating",
|
||||
"t_leetify_rating_rounds",
|
||||
"deaths",
|
||||
"has_banned_player",
|
||||
"kills",
|
||||
"party_size",
|
||||
]
|
||||
|
||||
games = games_from_profile(profile)
|
||||
games = map(lambda game: vals_in_order(game, cols), games)
|
||||
games = map(lambda game: vals_in_order(game, cols_api), games)
|
||||
|
||||
with conn.cursor() as curs:
|
||||
curs.executemany(
|
||||
f"""
|
||||
INSERT into data.profile_game ({', '.join(cols)})
|
||||
VALUES ({', '.join(['%s'] * len(cols))});
|
||||
INSERT into data.profile_game ({', '.join(cols_db)})
|
||||
VALUES ({', '.join(['%s'] * len(cols_db))});
|
||||
""",
|
||||
games,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue