fixed problem with duplicate entrances

This commit is contained in:
anon 2022-09-18 23:12:23 -03:00
parent deaf592d6e
commit 09f7ccdb58
4 changed files with 32 additions and 9 deletions

View file

@ -180,6 +180,8 @@ async def get_social_data(session, symbol):
#################################################################################### ####################################################################################
async def update_xmr_data(yesterday, coin): async def update_xmr_data(yesterday, coin):
name = coin.name name = coin.name
Coin.objects.filter(name=coin.name).filter(date=yesterday).delete()
url = 'https://xmrchain.net/api/networkinfo' url = 'https://xmrchain.net/api/networkinfo'
response = requests.get(url) response = requests.get(url)
data = json.loads(response.text) data = json.loads(response.text)

View file

@ -415,8 +415,6 @@ def update_database(date_from=None, date_to=None):
# Marketcap charts # Marketcap charts
data.btc_marketcap = coin_btc.priceusd*coin_btc.supply data.btc_marketcap = coin_btc.priceusd*coin_btc.supply
data.xmr_marketcap = coin_xmr.priceusd*coin_xmr.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.dash_marketcap = coin_dash.priceusd*coin_dash.supply
data.grin_marketcap = coin_grin.priceusd*coin_grin.supply data.grin_marketcap = coin_grin.priceusd*coin_grin.supply
data.zcash_marketcap = coin_zcash.priceusd*coin_zcash.supply data.zcash_marketcap = coin_zcash.priceusd*coin_zcash.supply

View file

@ -891,6 +891,29 @@ async def index(request):
if request.user.username != "Administrador" and request.user.username != "Morpheus": if request.user.username != "Administrador" and request.user.username != "Morpheus":
update_visitors(True) 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() dt = datetime.datetime.now(timezone.utc).timestamp()
coin = list(Coin.objects.order_by('-date'))[0] coin = list(Coin.objects.order_by('-date'))[0]
@ -901,6 +924,7 @@ async def index(request):
now = int(datetime.datetime.now().strftime("%H")) now = int(datetime.datetime.now().strftime("%H"))
yesterday = datetime.datetime.strftime(date.today() - timedelta(1), '%Y-%m-%d') 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_xmr = False
update_btc = False update_btc = False
@ -947,11 +971,10 @@ async def index(request):
except: except:
print('no coins found yesterday - 2') print('no coins found yesterday - 2')
update_btc = True update_btc = True
try:
coins_xmr = Coin.objects.filter(name='xmr').order_by('-date') coin_xmr = Coin.objects.filter(name='xmr').get(date=date_aux)
for coin_xmr in coins_xmr: except:
if coin_xmr.supply > 0: coin_xmr = list(Coin.objects.filter(name='xmr').order_by('-date'))[0]
break
if update_xmr: if update_xmr:
await asynchronous.update_xmr_data(yesterday, coin_xmr) await asynchronous.update_xmr_data(yesterday, coin_xmr)

View file

@ -28,8 +28,8 @@ STATICFILES_DIRS = [
SECRET_KEY = 'dafsdasdfasfa7sdfs9d7das7f9as7df8ad43525fsffdssdg455$$###77saf9df79as79s' SECRET_KEY = 'dafsdasdfasfa7sdfs9d7das7f9as7df8ad43525fsffdssdg455$$###77saf9df79as79s'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
#DEBUG = True DEBUG = True
DEBUG = False #DEBUG = False
ALLOWED_HOSTS = ['80.78.22.34', 'www.moneroj.net', 'localhost', '127.0.0.1', 'moneroj.net', 'moneroj5xq4ttg4ec7e5secqdyw5mcovzvfvlq6i7omv353i6mnexlqd.onion'] ALLOWED_HOSTS = ['80.78.22.34', 'www.moneroj.net', 'localhost', '127.0.0.1', 'moneroj.net', 'moneroj5xq4ttg4ec7e5secqdyw5mcovzvfvlq6i7omv353i6mnexlqd.onion']