| @@ -130,9 +130,6 @@ def get_kiriban_list ( | |||||
| latest_fetched_at = cast (date, (VideoHistory | latest_fetched_at = cast (date, (VideoHistory | ||||
| .where ('fetched_at', '<=', base_date) | .where ('fetched_at', '<=', base_date) | ||||
| .max ('fetched_at'))) | .max ('fetched_at'))) | ||||
| previous_fetched_at = cast (date, (VideoHistory | |||||
| .where ('fetched_at', '<', latest_fetched_at) | |||||
| .max ('fetched_at'))) | |||||
| for kiriban_views_count in KIRIBAN_VIEWS_COUNTS: | for kiriban_views_count in KIRIBAN_VIEWS_COUNTS: | ||||
| targets = { vh.video.code for vh in (VideoHistory | targets = { vh.video.code for vh in (VideoHistory | ||||
| @@ -143,7 +140,9 @@ def get_kiriban_list ( | |||||
| if code in [kiriban[1]['contentId'] for kiriban in kiriban_list]: | if code in [kiriban[1]['contentId'] for kiriban in kiriban_list]: | ||||
| continue | continue | ||||
| previous_views_count = cast (int, (VideoHistory | previous_views_count = cast (int, (VideoHistory | ||||
| .where ('code', code) | |||||
| .where_has ('videos', | |||||
| lambda q: q.where ( | |||||
| 'code', code)) | |||||
| .where ('fetched_at', '<', latest_fetched_at) | .where ('fetched_at', '<', latest_fetched_at) | ||||
| .max ('views_count'))) | .max ('views_count'))) | ||||
| if previous_views_count >= kiriban_views_count: | if previous_views_count >= kiriban_views_count: | ||||