4444from backend .internals .server import WebSocket
4545from backend .internals .settings import Settings
4646
47- THIRTY_DAYS = timedelta (days = 30 )
48- SECONDS_IN_DAY = 86400
4947# autopep8: off
48+ ONE_DAY = timedelta (days = 1 )
49+ THIRTY_DAYS = timedelta (days = 30 )
5050split_regex = compile (r'(?<!vs)(?<!r\.i\.p)(?:(?<=[\.!\?])\s|(?<=[\.!\?]</p>)(?!$))' , IGNORECASE )
5151remove_link_regex = compile (r'<a[^>]*>.*?</a>' , IGNORECASE )
5252omnibus_regex = compile (r'\bomnibus\b' , IGNORECASE )
@@ -1537,8 +1537,9 @@ def refresh_and_scan(
15371537 """
15381538 cursor = get_db ()
15391539
1540- one_day_ago = round (time ()) - SECONDS_IN_DAY
1541- five_days_ago = round (time ()) - (5 * SECONDS_IN_DAY )
1540+ current_time = datetime .now ()
1541+ one_day_ago = current_time - ONE_DAY
1542+ thirty_days_ago = current_time - THIRTY_DAYS
15421543 if volume_id :
15431544 cursor .execute ("""
15441545 SELECT comicvine_id, id, last_cv_fetch
@@ -1564,7 +1565,7 @@ def refresh_and_scan(
15641565 WHERE last_cv_fetch <= ?
15651566 ORDER BY last_cv_fetch ASC;
15661567 """ ,
1567- (one_day_ago ,)
1568+ (one_day_ago . timestamp () ,)
15681569 )
15691570
15701571 cv_to_id_fetch : Dict [int , Tuple [int , int ]] = {
@@ -1589,14 +1590,14 @@ def refresh_and_scan(
15891590 WHERE v.last_cv_fetch <= ?
15901591 GROUP BY i.volume_id;
15911592 """ ,
1592- (one_day_ago ,)
1593+ (one_day_ago . timestamp () ,)
15931594 ))
15941595
15951596 filtered_volume_datas = [
15961597 v
15971598 for v in volume_datas
15981599 if cv_id_to_issue_count [v ["comicvine_id" ]] != v ["issue_count" ]
1599- or cv_to_id_fetch [v ["comicvine_id" ]][1 ] <= five_days_ago
1600+ or cv_to_id_fetch [v ["comicvine_id" ]][1 ] <= thirty_days_ago . timestamp ()
16001601 ]
16011602
16021603 cursor .executemany (
@@ -1624,7 +1625,7 @@ def refresh_and_scan(
16241625 "description" : vd ["description" ],
16251626 "site_url" : vd ["site_url" ],
16261627 "cover" : vd ["cover" ],
1627- "last_cv_fetch" : one_day_ago + SECONDS_IN_DAY ,
1628+ "last_cv_fetch" : current_time . timestamp () ,
16281629
16291630 "id" : cv_to_id_fetch [vd ["comicvine_id" ]][0 ]
16301631 }
0 commit comments