diff --git a/.gitignore b/.gitignore index bee8a64..c0d27a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__ +connection.py diff --git a/models.py b/models.py index d50591b..8dd09b3 100644 --- a/models.py +++ b/models.py @@ -2,7 +2,22 @@ from __future__ import annotations from datetime import datetime -from eloquent import Model +from eloquent import Model # type: ignore + + +class AnsweredFlag (Model): + id: int + answer_id: int + platform: int + answered: bool + + __timestamps__ = False + + @property + def answer ( + self, + ) -> Answer: + return self.belongs_to (Answer) class Answer (Model): @@ -12,7 +27,6 @@ class Answer (Model): content: str answer_type: int sent_at: datetime - answered: bool __timestamps__ = False @@ -22,6 +36,17 @@ class Answer (Model): ) -> Query: return self.belongs_to (Query) + def answered ( + self, + platform: int, + ) -> bool | None: + answered_flag = (AnsweredFlag.where ('answer_id', self.id) + .where ('platform', platform) + .first ()) + if answered_flag is None: + return None + return answered_flag.answered + class Query (Model): id: int