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