Skip to content

Commit

Permalink
Fix update of volatile rates
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Kozarin committed Apr 28, 2023
1 parent c84c8a4 commit 44e8c66
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/strconv/currates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ def update_rates(src: Iterable[DataSource]) -> None:
:raises ExternalServiceError: if something bad happened while executing request
"""

src = list(src)

global __src_cache
if len(__src_cache) == 0:
_logger.info("Filling the cache of currency rates sources...")
__src_cache = src = list(src)
__src_cache = src

today = datetime.datetime.utcnow().date()
if 'date' in __db and __db['date'].decode() == str(today):
volatile = all(x.volatile for x in src)
if not volatile and 'date' in __db and __db['date'].decode() == str(today):
_logger.info("The cache already has the actual currency exchange rates. Skipping...")
return

Expand Down

0 comments on commit 44e8c66

Please sign in to comment.