Merge pull request #4 from IgorVolochay/frontend

This commit is contained in:
IgorVolochay
2026-09-01 17:26:42 +03:00
parent 73d16e9111
commit 61a2eb8076
52 changed files with 3785 additions and 752 deletions
+6 -4
View File
@@ -41,10 +41,12 @@ def write_json(cards_list, json_file):
except Exception as e:
print(f"Error writing to JSON file: {e}")
def add_cards_to_mongodb(cards_list):
import asyncio
async def add_cards_to_mongodb(cards_list):
mongo = MongoWorker()
for card in cards_list:
mongo.add_card_by_base_model(card)
await mongo.add_card_by_base_model(card)
print(f"Successfully added {len(cards_list)} cards to MongoDB")
@@ -60,13 +62,13 @@ if __name__ == "__main__":
if args.action == 0:
cards = create_cards(args.num, args.user)
add_cards_to_mongodb(cards)
asyncio.run(add_cards_to_mongodb(cards))
elif args.action == 1:
cards = create_cards(args.num, args.user)
write_json(cards, args.file)
elif args.action == 2:
cards = read_json(args.file)
if cards:
add_cards_to_mongodb(cards)
asyncio.run(add_cards_to_mongodb(cards))
else:
print("No valid cards found in JSON file.")