# 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')