feat: add /select_choice route

This commit is contained in:
IgorVolochay
2025-03-04 17:25:03 +03:00
parent 62d085b898
commit 2c545dc961
7 changed files with 50 additions and 14 deletions
+10 -1
View File
@@ -83,7 +83,7 @@ class MongoWorker:
return Visited.model_validate(update_visited)
def add_card(self, choice_A: str, choice_B: str, author_id: int) -> Card:
def add_card_by_api(self, choice_A: str, choice_B: str, author_id: int) -> Card:
new_card = Card(card_id=self.get_and_update_counter(counter_name="card"),
choice_A=choice_A,
choice_B=choice_B,
@@ -96,6 +96,15 @@ class MongoWorker:
print(exception)
return new_card
def add_card_by_base_model(self, new_card: Card) -> Card:
new_card.card_id = self.get_and_update_counter(counter_name="card")
try:
self.game_data.insert_one(new_card.model_dump())
return new_card
except Exception as exception:
print(exception)
return new_card
def get_card(self, card_id: int) -> Optional[Card]:
document = self.game_data.find_one({"card_id": card_id})
if document: