|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- # pylint: disable = missing-class-docstring
- # pylint: disable = missing-function-docstring
-
- """
- ぼざクリ DB の構成
- """
-
- from __future__ import annotations
-
- from datetime import date, datetime
-
- from db.my_eloquent import Model
-
-
- class Comment (Model):
- # pylint: disable = too-many-instance-attributes
-
- id: int
- video_id: int
- comment_no: int
- user_id: int
- content: str
- posted_at: datetime
- nico_count: int
- vpos_ms: int
-
- __timestamps__ = False
-
- @property
- def video (
- self,
- ) -> Video:
- return self.belongs_to (Video)
-
- @property
- def user (
- self,
- ) -> User:
- return self.belongs_to (User)
-
- def upsert (
- self,
- *args: str,
- ) -> None:
- super ().upsert ('video_id', 'comment_no')
-
-
- class Tag (Model):
- id: int
- name: str
-
- __timestamps__ = False
-
- @property
- def video_tags (
- self,
- ) -> list[VideoTag]:
- return self.has_many (VideoTag)
-
-
- class User (Model):
- id: int
- code: str
-
- __timestamps__ = False
-
- @property
- def comments (
- self,
- ) -> list[Comment]:
- return self.has_many (Comment)
-
-
- class Video (Model):
- id: int
- code: str
- title: str
- description: str
- uploaded_at: datetime
- deleted_at: datetime | None
-
- __timestamps__ = False
-
- @property
- def video_histories (
- self,
- ) -> list[VideoHistory]:
- return self.has_many (VideoHistory)
-
- @property
- def video_tags (
- self,
- ) -> list[VideoTag]:
- return self.has_many (VideoTag)
-
- @property
- def comments (
- self,
- ) -> list[Comment]:
- return self.has_many (Comment)
-
- def upsert (
- self,
- *args: str,
- ) -> None:
- super ().upsert ('code')
-
-
- class VideoHistory (Model):
- id: int
- video_id: int
- fetched_at: date
- views_count: int
-
- __timestamps__ = False
-
- @property
- def video (
- self,
- ) -> Video:
- return self.belongs_to (Video)
-
- def upsert (
- self,
- *args: str,
- ) -> None:
- super ().upsert ('video_id', 'fetched_at')
-
-
- class VideoTag (Model):
- id: int
- video_id: int
- tag_id: int
- tagged_at: date
- untagged_at: date | None
-
- __timestamps__ = False
-
- @property
- def video (
- self,
- ) -> Video:
- return self.belongs_to (Video)
-
- @property
- def tag (
- self,
- ) -> Tag:
- return self.belongs_to (Tag)
-
- def upsert (
- self,
- *args: str,
- ) -> None:
- super ().upsert ('video_id', 'tag_id')
|