mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 03:16:24 +00:00
Fix bug when caching np.nan prices
This commit is contained in:
parent
28bfaee937
commit
9009f35269
@ -10,7 +10,6 @@ from django.db.models import Q
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from decouple import config
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@shared_task(name="users_cleansing")
|
@shared_task(name="users_cleansing")
|
||||||
@ -21,12 +20,11 @@ def users_cleansing():
|
|||||||
# Users who's last login has not been in the last 12 hours
|
# Users who's last login has not been in the last 12 hours
|
||||||
active_time_range = (timezone.now() - timedelta(hours=12), timezone.now())
|
active_time_range = (timezone.now() - timedelta(hours=12), timezone.now())
|
||||||
queryset = User.objects.filter(~Q(last_login__range=active_time_range))
|
queryset = User.objects.filter(~Q(last_login__range=active_time_range))
|
||||||
|
queryset = queryset(is_staff=False) # Do not delete staff users
|
||||||
|
|
||||||
# And do not have an active trade or any pass finished trade.
|
# And do not have an active trade or any pass finished trade.
|
||||||
deleted_users = []
|
deleted_users = []
|
||||||
for user in queryset:
|
for user in queryset:
|
||||||
if user.username == str(config('ESCROW_USERNAME')): # Do not delete admin user by mistake
|
|
||||||
continue
|
|
||||||
if not user.profile.total_contracts == 0:
|
if not user.profile.total_contracts == 0:
|
||||||
continue
|
continue
|
||||||
valid, _ = Logics.validate_already_maker_or_taker(user)
|
valid, _ = Logics.validate_already_maker_or_taker(user)
|
||||||
@ -94,6 +92,7 @@ def cache_market():
|
|||||||
for val in Currency.currency_dict:
|
for val in Currency.currency_dict:
|
||||||
rate = exchange_rates[int(val)-1] # currecies are indexed starting at 1 (USD)
|
rate = exchange_rates[int(val)-1] # currecies are indexed starting at 1 (USD)
|
||||||
results[val] = {Currency.currency_dict[val], rate}
|
results[val] = {Currency.currency_dict[val], rate}
|
||||||
|
if str(rate) == 'nan': continue # Do not update if no new rate was found
|
||||||
|
|
||||||
# Create / Update database cached prices
|
# Create / Update database cached prices
|
||||||
Currency.objects.update_or_create(
|
Currency.objects.update_or_create(
|
||||||
@ -101,7 +100,7 @@ def cache_market():
|
|||||||
currency = int(val),
|
currency = int(val),
|
||||||
# if there is a Cached market prices matching that id, it updates it with defaults below
|
# if there is a Cached market prices matching that id, it updates it with defaults below
|
||||||
defaults = {
|
defaults = {
|
||||||
'exchange_rate': rate,
|
'exchange_rate': float(rate),
|
||||||
'timestamp': timezone.now(),
|
'timestamp': timezone.now(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user