|
@@ -2,7 +2,22 @@ from __future__ import annotations |
|
|
|
|
|
|
|
|
from datetime import datetime |
|
|
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): |
|
|
class Answer (Model): |
|
@@ -12,7 +27,6 @@ class Answer (Model): |
|
|
content: str |
|
|
content: str |
|
|
answer_type: int |
|
|
answer_type: int |
|
|
sent_at: datetime |
|
|
sent_at: datetime |
|
|
answered: bool |
|
|
|
|
|
|
|
|
|
|
|
__timestamps__ = False |
|
|
__timestamps__ = False |
|
|
|
|
|
|
|
@@ -22,6 +36,17 @@ class Answer (Model): |
|
|
) -> Query: |
|
|
) -> Query: |
|
|
return self.belongs_to (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): |
|
|
class Query (Model): |
|
|
id: int |
|
|
id: int |
|
|