From ae822b7b580f00a8b2cef02aa65b39e19c125a1c Mon Sep 17 00:00:00 2001 From: miteruzo Date: Wed, 18 Dec 2024 03:56:51 +0000 Subject: [PATCH 1/2] to ignore connection --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bee8a64..c0d27a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__ +connection.py From 3ca5f7c83f5f23ece55de18d626aca3f4648502b Mon Sep 17 00:00:00 2001 From: miteruzo Date: Thu, 19 Dec 2024 00:28:42 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=81=BC=E3=81=A1=E3=81=BC=E3=81=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) 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