Fix for new prices structure (#47)

This commit is contained in:
Mark Cheese 2020-01-21 15:39:48 -05:00 committed by Zach H
parent 2deb975e89
commit 6988b47ca4

View file

@ -669,22 +669,21 @@ def parse_and_import_extras(input_file: pathlib.Path, output_file: Dict) -> None
"r", encoding="utf8" "r", encoding="utf8"
) as f: ) as f:
json_data = json.load(f) json_data = json.load(f)
for card_uuid in json_data: for card_uuid, price_data in json_data.items():
for price_type in json_data[card_uuid]["prices"]: for price_type, price_dict in price_data["prices"].items():
for price_date, price_value in json_data[card_uuid]["prices"][ if not price_type == "uuid":
price_type for price_date, price_value in price_dict.items():
].items(): if price_value:
if price_value: sql_dict_insert(
sql_dict_insert( {
{ "uuid": card_uuid,
"uuid": card_uuid, "type": price_type,
"type": price_type, "date": price_date,
"date": price_date, "price": float(price_value),
"price": float(price_value), },
}, "prices",
"prices", output_file,
output_file, )
)
if output_file["useAllDeckFiles"]: if output_file["useAllDeckFiles"]:
LOGGER.info("Inserting Deck rows") LOGGER.info("Inserting Deck rows")
@ -988,7 +987,7 @@ def modify_for_sql_insert(data: Any) -> Union[str, int, float, None]:
return None return None
if isinstance(data, list) and data and isinstance(data[0], str): if isinstance(data, list) and data and isinstance(data[0], str):
return ", ".join(data) return ",".join(data)
if isinstance(data, bool): if isinstance(data, bool):
return int(data) return int(data)
@ -998,7 +997,7 @@ def modify_for_sql_insert(data: Any) -> Union[str, int, float, None]:
return "" return ""
def modify_for_sql_file(data: Any) -> Union[str, int, float, None]: def modify_for_sql_file(data: Dict[str, Any]) -> Dict[str, Any]:
for key in data.keys(): for key in data.keys():
if isinstance(data[key], str): if isinstance(data[key], str):
data[key] = ( data[key] = (