feat: add /select_choice route
This commit is contained in:
+10
-1
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user