From 5eb3fb6037a5b8fbf1922ea91ef519b80542649f Mon Sep 17 00:00:00 2001 From: miteruzo Date: Mon, 14 Oct 2024 18:16:56 +0900 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E3=81=95=E3=82=8C=E3=81=9F=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E3=82=92=E5=86=8D=E7=99=BB=E9=8C=B2=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=A6=E3=81=AA=E3=81=83=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update_db.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/update_db.py b/update_db.py index 5f43424..3d551a0 100644 --- a/update_db.py +++ b/update_db.py @@ -141,7 +141,6 @@ def update_tables ( api_data: list[VideoResult], now: datetime, ) -> None: - video_ids: list[int] = [] for datum in api_data: tag_names: list[str] = datum['tags'].split () video = VideoDto (code = datum['contentId'], @@ -150,7 +149,6 @@ def update_tables ( uploaded_at = datetime.fromisoformat (datum['startTime'])) video_dao.upsert (video, False) if video.id_ is not None: - video_ids.append (video.id_) video_history = VideoHistoryDto (video_id = video.id_, fetched_at = now, views_count = datum['viewCounter']) @@ -160,7 +158,7 @@ def update_tables ( for vt in video_tags: tag = tag_dao.find (vt.tag_id) if (tag is not None - and (tag.name.upper () not in [tn.upper () for tn in tag_names]) + and (tag.name.upper () not in map (str.upper, tag_names)) and (tag.id_ is not None)): tag_ids.append (tag.id_) video_tag_dao.untag_all (video.id_, tag_ids, now) @@ -535,7 +533,7 @@ class VideoTagDao: video_tags WHERE video_id = %s - AND (untagged_at IS NULL) + AND untagged_at IS NULL ORDER BY id""", (video_id,)) print (c._executed) @@ -562,7 +560,8 @@ class VideoTagDao: video_tags WHERE video_id = %s - AND tag_id = %s""", (video_id, tag_id)) + AND tag_id = %s + AND untagged_at IS NULL""", (video_id, tag_id)) print (c._executed) row = cast (VideoTagRow, c.fetchone ()) if row is None: