From 09f7ccdb585c2c30bf3b991a1d60c6ed82c9a3ec Mon Sep 17 00:00:00 2001 From: anon Date: Sun, 18 Sep 2022 23:12:23 -0300 Subject: [PATCH] fixed problem with duplicate entrances --- charts/asynchronous.py | 2 ++ charts/synchronous.py | 2 -- charts/views.py | 33 ++++++++++++++++++++++++++++----- moneropro/settings.py | 4 ++-- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/charts/asynchronous.py b/charts/asynchronous.py index c0604da..477c6a8 100644 --- a/charts/asynchronous.py +++ b/charts/asynchronous.py @@ -180,6 +180,8 @@ async def get_social_data(session, symbol): #################################################################################### async def update_xmr_data(yesterday, coin): name = coin.name + Coin.objects.filter(name=coin.name).filter(date=yesterday).delete() + url = 'https://xmrchain.net/api/networkinfo' response = requests.get(url) data = json.loads(response.text) diff --git a/charts/synchronous.py b/charts/synchronous.py index 66c1d9e..19efd84 100644 --- a/charts/synchronous.py +++ b/charts/synchronous.py @@ -415,8 +415,6 @@ def update_database(date_from=None, date_to=None): # Marketcap charts data.btc_marketcap = coin_btc.priceusd*coin_btc.supply data.xmr_marketcap = coin_xmr.priceusd*coin_xmr.supply - print(coin_dash.priceusd) - print(coin_dash.supply) data.dash_marketcap = coin_dash.priceusd*coin_dash.supply data.grin_marketcap = coin_grin.priceusd*coin_grin.supply data.zcash_marketcap = coin_zcash.priceusd*coin_zcash.supply diff --git a/charts/views.py b/charts/views.py index 2ee6f84..bed547f 100644 --- a/charts/views.py +++ b/charts/views.py @@ -891,6 +891,29 @@ async def index(request): if request.user.username != "Administrador" and request.user.username != "Morpheus": update_visitors(True) + # coins = Coin.objects.filter(name='xmr').order_by('-date') + # for coin in coins: + # if '2022-09-17' == datetime.datetime.strftime(coin.date, '%Y-%m-%d'): + # coin.supply = 18175769 + # coin.save() + # print('saved') + # if '2022-09-16' == datetime.datetime.strftime(coin.date, '%Y-%m-%d'): + # coin.supply = 18175284 + # coin.save() + # print('saved') + # if '2022-09-15' == datetime.datetime.strftime(coin.date, '%Y-%m-%d'): + # coin.supply = 18174852 + # coin.save() + # print('saved') + # coins_aux = Coin.objects.filter(name='xmr').filter(date=coin.date) + # count = 1 + # for coin_aux in coins_aux: + # if count > 1: + # print('deleted one') + # print(coin_aux.date) + # coin_aux.delete() + # count += 1 + dt = datetime.datetime.now(timezone.utc).timestamp() coin = list(Coin.objects.order_by('-date'))[0] @@ -901,6 +924,7 @@ async def index(request): now = int(datetime.datetime.now().strftime("%H")) yesterday = datetime.datetime.strftime(date.today() - timedelta(1), '%Y-%m-%d') + date_aux = datetime.datetime.strftime(date.today() - timedelta(2), '%Y-%m-%d') update_xmr = False update_btc = False @@ -947,11 +971,10 @@ async def index(request): except: print('no coins found yesterday - 2') update_btc = True - - coins_xmr = Coin.objects.filter(name='xmr').order_by('-date') - for coin_xmr in coins_xmr: - if coin_xmr.supply > 0: - break + try: + coin_xmr = Coin.objects.filter(name='xmr').get(date=date_aux) + except: + coin_xmr = list(Coin.objects.filter(name='xmr').order_by('-date'))[0] if update_xmr: await asynchronous.update_xmr_data(yesterday, coin_xmr) diff --git a/moneropro/settings.py b/moneropro/settings.py index 6b8403f..a15ec5a 100644 --- a/moneropro/settings.py +++ b/moneropro/settings.py @@ -28,8 +28,8 @@ STATICFILES_DIRS = [ SECRET_KEY = 'dafsdasdfasfa7sdfs9d7das7f9as7df8ad43525fsffdssdg455$$###77saf9df79as79s' # SECURITY WARNING: don't run with debug turned on in production! -#DEBUG = True -DEBUG = False +DEBUG = True +#DEBUG = False ALLOWED_HOSTS = ['80.78.22.34', 'www.moneroj.net', 'localhost', '127.0.0.1', 'moneroj.net', 'moneroj5xq4ttg4ec7e5secqdyw5mcovzvfvlq6i7omv353i6mnexlqd.onion']