video_histories への書込みを Upsert に
このコミットが含まれているのは:
バイナリファイルは表示されません.
バイナリファイルは表示されません.
バイナリファイルは表示されません.
+12
-1
@@ -1,3 +1,10 @@
|
||||
# pylint: disable = missing-class-docstring
|
||||
# pylint: disable = missing-function-docstring
|
||||
|
||||
"""
|
||||
みてるぞ式魔改造(言ふほどか?)版 Eloquent
|
||||
"""
|
||||
|
||||
import eloquent
|
||||
|
||||
|
||||
@@ -6,6 +13,8 @@ class DatabaseManager (eloquent.DatabaseManager):
|
||||
|
||||
|
||||
class Model (eloquent.Model):
|
||||
id: int
|
||||
|
||||
def upsert (
|
||||
self,
|
||||
*args: str,
|
||||
@@ -16,5 +25,7 @@ class Model (eloquent.Model):
|
||||
row = q.first ()
|
||||
if row is not None:
|
||||
self.id = row.id
|
||||
self._Model__exists = True # pylint: disable = protected-access
|
||||
# pylint: disable = invalid-name
|
||||
# pylint: disable = attribute-defined-outside-init
|
||||
self._Model__exists = True
|
||||
self.save ()
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ def update_tables (
|
||||
video_history.video_id = video.id
|
||||
video_history.fetched_at = now
|
||||
video_history.views_count = datum['viewCounter']
|
||||
video_history.save ()
|
||||
video_history.upsert ()
|
||||
video_tags = [video_tag for video_tag in video.video_tags
|
||||
if video_tag.untagged_at is not None]
|
||||
tag: Tag | None
|
||||
|
||||
新しい課題から参照
ユーザをブロックする