Fix performance issue for users with many orders

This commit is contained in:
2026-05-24 12:50:52 +02:00
parent 7856123bc0
commit 3591e0f33a
6 changed files with 136 additions and 22 deletions

View File

@@ -81,8 +81,13 @@ def import_csv(filepath: str):
lambda: defaultdict(lambda: Order(user_id=1))
)
for row in rows:
for i, row in enumerate(rows, start=2):
transaction_type = row["typ"].lower()
if transaction_type == "einkauf foodcoop":
print(
"Skipping 'Einkauf Foodcoop' transaction as it's not relevant for the payment system."
)
continue
if transaction_type not in [
"essen",
"essen kind",
@@ -90,8 +95,9 @@ def import_csv(filepath: str):
"einkauf",
"auszahlung",
]:
# TODO: Handle other types
continue
raise ValueError(
f"Skipping row {i} with unknown transaction type: '{transaction_type}'"
)
# find or create account for "Partei/Konto"
account_name = row["partei_konto"]
@@ -123,7 +129,7 @@ def import_csv(filepath: str):
if transaction_type == "essen"
else kids_meal_product
),
total_amount=row["betrag"],
total_amount=row["betrag"] * -1,
quantity=quantity,
)
)