Skip to content

Commit

Permalink
Add country field for static tables
Browse files Browse the repository at this point in the history
  • Loading branch information
martinszy committed Aug 21, 2024
1 parent 80ea81d commit 4599600
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions static_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def read_country_tables(country):

del area["area_id"]

area["country"] = country

# CHAMBER
chamber_data[country] = sheet_reader(SHEET_ID, f"Table chamber!{ST_RANGES['chamber']}")
chamber_header = chamber_data[country][0].keys()
Expand All @@ -43,6 +45,7 @@ def read_country_tables(country):
if chamber["chamber_id"] == "":
chamber["is_deleted"] = True
del chamber["chamber_id"]
chamber["country"] = country

# ROLE
role_data[country] = sheet_reader(SHEET_ID, f"Table role!{ST_RANGES['role']}")
Expand All @@ -52,6 +55,7 @@ def read_country_tables(country):
if role["role_id"] == "":
role["is_deleted"] = True
del role["role_id"]
role["country"] = country

# COALITION
coalition_data[country] = sheet_reader(SHEET_ID,
Expand All @@ -62,6 +66,8 @@ def read_country_tables(country):
coalition_data[country] = colors_to_list(coalition_data[country])
for coalition in coalition_data[country]:
del coalition["coalition_id"]
coalition["country"] = country

coalitions_catalogue[country] = sheet_reader(SHEET_ID, f"Table coalition!B2:B{get_end_range(ST_RANGES['coalition'])}",
as_list=True)

Expand All @@ -73,6 +79,9 @@ def read_country_tables(country):
for party in party_data[country]:
if party["party_id"] == "":
party["is_deleted"] = True
party["country"] = country
party["party_id"] = country+"-"+party["party_id"]

# del party["party_id"]


Expand All @@ -87,6 +96,8 @@ def read_country_tables(country):
if contest["contest_id"] == "":
contest["is_deleted"] = True
del contest["contest_id"]
contest["country"] = country


contest_chambers[country] = sheet_reader(SHEET_ID, f"Table contest!C2:G{get_end_range(ST_RANGES['contest'])}",
as_list=True)
Expand All @@ -98,6 +109,8 @@ def read_country_tables(country):
f"{CSV_DB_PATH}/profession")
for profession in profession_data[country]:
del profession["profession_id"]
profession["country"] = country

professions_catalogue[country] = sheet_reader(SHEET_ID, f"Catalogue profession!B2:B{get_end_range(ST_RANGES['profession'])}",
as_list=True)
# print(professions_catalogue[country])
Expand Down
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def send_data(base_url, endpoint, dataset):
if post_status != 201:
print(f"#{i} POST: {post_status} CREATE: {post_status}")
print("i",i)
print("created dummy 1",r.json());
print("created dummy 1",r);
print("row",row)
r2 = requests.delete(f"{full_url}{i}", headers=HEADERS)
delete_status = r2.status_code
Expand Down

0 comments on commit 4599600

Please sign in to comment.