Commit 0e0d9367 authored by Barkin Simsek's avatar Barkin Simsek 🐢
Browse files

Fix issues with UpdateFetcher not updating the list on first boot (#77)

parent 71bcc368
Pipeline #7402 failed with stages
in 1 minute and 7 seconds
import logging
from typing import Dict, List
from datetime import datetime
from datetime import datetime, timedelta
import pytz
from sqlalchemy.orm import sessionmaker
......@@ -75,6 +75,9 @@ class UpdateRelays:
current_datetime = datetime.now()
current_datetime_str = current_datetime.strftime(self.__datetime_format)
one_hour_earlier_str = (datetime.now() - timedelta(hours=1)).strftime(
self.__datetime_format
)
# Check if it exists in the database
if query.count() == 0:
......@@ -85,7 +88,7 @@ class UpdateRelays:
)
self.__db_session.add(metadata)
self.__db_session.commit()
return datetime.strptime(current_datetime_str, self.__datetime_format)
return datetime.strptime(one_hour_earlier_str, self.__datetime_format)
# Get and return the existing value
date_from_db = query.one().value
......
......@@ -52,7 +52,7 @@ class TestUpdateRelays(unittest.TestCase):
config=self.config, db_session=self.db_session, auto_update=False
)
self.assertEqual(update_relays._UpdateRelays__hours_since_last_update(), 0)
self.assertEqual(update_relays._UpdateRelays__hours_since_last_update(), 1)
# Call again in the simulated future
with freeze_time("2100-01-01"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment