みてるぞ 4 weeks ago
parent
commit
215d54b988
2 changed files with 28 additions and 2 deletions
  1. +1
    -0
      .gitignore
  2. +27
    -2
      models.py

+ 1
- 0
.gitignore View File

@@ -1 +1,2 @@
__pycache__
connection.py

+ 27
- 2
models.py View File

@@ -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


Loading…
Cancel
Save