fixing bugs

This commit is contained in:
Morpheus 2023-10-01 01:57:53 -03:00
parent 34318c5348
commit 1482082dcf
9 changed files with 102 additions and 109 deletions

View file

@ -12,11 +12,11 @@ import pygsheets
# Asynchronous get block data from xmrchain # Asynchronous get block data from xmrchain
#################################################################################### ####################################################################################
async def get_block_data(session, block: str): async def get_block_data(session, block: str):
url = 'https://xmrchain.net/api/block/' + block url = 'https://localmonero.co/blocks/api/get_block_data/' + block
async with session.get(url) as res: async with session.get(url) as res:
data = await res.read() data = await res.read()
data = json.loads(data) data = json.loads(data)
data['provider'] = 'xmrchain' data['provider'] = 'localmonero'
if res.status < 299: if res.status < 299:
data['success'] = True data['success'] = True
else: else:
@ -174,12 +174,13 @@ async def update_xmr_data(yesterday, coin):
name = coin.name name = coin.name
Coin.objects.filter(name=coin.name).filter(date=yesterday).delete() Coin.objects.filter(name=coin.name).filter(date=yesterday).delete()
url = 'https://xmrchain.net/api/networkinfo' url = 'https://localmonero.co/blocks/api/get_stats'
response = requests.get(url) response = requests.get(url)
data = json.loads(response.text) data = json.loads(response.text)
height = int(data['data']['height']) height = int(data['height'])
difficulty = int(data['data']['difficulty']) difficulty = int(data['difficulty'])
hashrate = int(data['data']['hash_rate']) hashrate = int(data['hashrate'])
supply = int(data['total_emission'])
blocksize = 0 blocksize = 0
actions = [] actions = []
@ -215,12 +216,12 @@ async def update_xmr_data(yesterday, coin):
for response in responses: for response in responses:
if response: if response:
try: try:
if response['provider'] == 'xmrchain': if response['provider'] == 'localmonero':
date_aux = response['data']['timestamp_utc'].split(' ')[0] date_aux = response['block_header']['timestamp']
if date_aux == yesterday: if date_aux == yesterday:
try: try:
blocksize += int(response['data']['size']) blocksize += int(response['block_header']['size'])
for tx in response['data']['txs']: for tx in response['block_header']['txs']:
if tx['coinbase']: if tx['coinbase']:
revenue += int(tx['xmr_outputs']) revenue += int(tx['xmr_outputs'])
else: else:

View file

@ -258,6 +258,22 @@ def update_rank(data=None):
def check_new_social(symbol): def check_new_social(symbol):
yesterday = datetime.datetime.strftime(date.today()-timedelta(1), '%Y-%m-%d') yesterday = datetime.datetime.strftime(date.today()-timedelta(1), '%Y-%m-%d')
socials = Social.objects.filter(name=symbol).filter(date=yesterday) socials = Social.objects.filter(name=symbol).filter(date=yesterday)
if symbol == 'Bitcoin':
timeframe = 14400
hours = 86400/timeframe
timeframe2 = 3600
hours2 = 86400/timeframe2
elif symbol == 'Monero':
timeframe = 43200
hours = 86400/timeframe
timeframe2 = 43200
hours2 = 86400/timeframe2
elif symbol == 'Cryptocurrency':
timeframe = 14400
hours = 86400/timeframe
timeframe2 = 1800
hours2 = 86400/timeframe2
if not(socials): if not(socials):
print('new social') print('new social')
request = 'https://www.reddit.com/r/'+ symbol +'/about.json' request = 'https://www.reddit.com/r/'+ symbol +'/about.json'
@ -275,20 +291,20 @@ def check_new_social(symbol):
date_aux = datetime.datetime.strptime(date_aux, '%Y-%m-%d') date_aux = datetime.datetime.strptime(date_aux, '%Y-%m-%d')
timestamp1 = int(datetime.datetime.timestamp(date_aux)) timestamp1 = int(datetime.datetime.timestamp(date_aux))
timestamp2 = int(timestamp1 - 43200) timestamp2 = int(timestamp1 - timeframe)
limit = 1000 limit = 1000
filters = [] filters = []
data = data_prep_posts(symbol, timestamp2, timestamp1, filters, limit) data = data_prep_posts(symbol, timestamp2, timestamp1, filters, limit)
if data != 0: if data != 0:
social.postsPerHour = len(data)/12 social.postsPerHour = len(data)/hours
else: else:
social.postsPerHour = 0 social.postsPerHour = 0
timestamp2 = int(timestamp1 - 3600) timestamp2 = int(timestamp1 - timeframe2)
limit = 1000 limit = 1000
data = data_prep_comments(symbol, timestamp2, timestamp1, filters, limit) data = data_prep_comments(symbol, timestamp2, timestamp1, filters, limit)
if data != 0: if data != 0:
social.commentsPerHour = len(data)/1 social.commentsPerHour = len(data)/hours2
else: else:
social.commentsPerHour = 0 social.commentsPerHour = 0
social.save() social.save()
@ -549,7 +565,7 @@ def update_database(date_from=None, date_to=None):
data.crypto_postsPerHour = 0 data.crypto_postsPerHour = 0
data.save() data.save()
print(str(coin_xmr.date) + ' xmr ' + str(data.xmr_subscriberCount) + ' - ' + str(social_xmr.subscriberCount) + ' = ' + str(int(data.xmr_marketcap)) + ' => ' + str(coin_xmr.inflation)) print(str(coin_xmr.supply) + ' xmr ' + str(data.xmr_subscriberCount) + ' - ' + str(social_xmr.subscriberCount) + ' = ' + str(int(data.xmr_marketcap)) + ' => ' + str(coin_xmr.inflation))
count += 1 count += 1

View file

@ -58,7 +58,7 @@
</div> </div>
</div> </div>
<div class="col-xl-4 d-flex justify-content-center align-items-center"> <div class="col-xl-4 d-flex justify-content-center align-items-center">
<!-- <iframe src="https://trocador.app/step1/?ref=pbhBEQR5WU" style="border:0px white solid;height:395px;width:100%;" scrolling="no"></iframe> --> <iframe src="https://trocador.app/step1/?ref=pbhBEQR5WU" style="border:0px white solid;height:395px;width:100%;" scrolling="no"></iframe>
</div> </div>
</div> </div>
<br><br> <br><br>
@ -511,6 +511,7 @@
</div> </div>
</section> </section>
<!-- End F.A.Q Section --> <!-- End F.A.Q Section -->
<!-- ======= Services Section ======= --> <!-- ======= Services Section ======= -->
<section id="services" class="services"> <section id="services" class="services">
<div class="container"> <div class="container">
@ -518,49 +519,49 @@
<div class="section-title"> <div class="section-title">
<h2>Partners</h2> <h2>Partners</h2>
<div class="row"> <div class="row" style="padding:0 0px;width:100%;margin:0;">
<div class="col-lg-6"> <div class="col-lg-12 d-flex justify-content-center" style="padding:5px 0;flex-wrap: wrap;max-width: 1110px;margin-left: auto;margin-right: auto;">
<div class="row">
<div class="col"> <div class="col" style="display:inline-block;min-width: 110px;max-width: 110px;padding:5px 5px;">
<a href="https://exch.cx/?ref=F16db5Ee" target="_blank"> <a href="https://exch.cx/?ref=F16db5Ee" target="_blank">
<img src="../../../static/img/Exch_square.png" width="250" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px; border-color: #313030; border-style: solid; border-width: 2px;"> <img src="../../../static/img/Exch_square.png" width="100" height="100" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px; border-color: #313030; border-style: solid; border-width: 2px;">
</a> </a>
</div> </div>
<div class="col"> <div class="col" style="display:inline-block;min-width: 110px;max-width: 110px;padding:5px 5px;">
<a href="https://swapuz.com/?ref=9c2b7390-eba1-4919-8c4a-f4573d666e32" target="_blank"> <a href="https://swapuz.com/?ref=9c2b7390-eba1-4919-8c4a-f4573d666e32" target="_blank">
<img src="../../../static/img/Swapuz_square.png" width="250" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;"> <img src="../../../static/img/Swapuz_square.png" width="100" height="100" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;">
</a> </a>
</div> </div>
<div class="col"> <div class="col" style="display:inline-block;min-width: 110px;max-width: 110px;padding:5px 5px;">
<a href="https://exolix.com/?ref=0FAB49E2F09EFBCB0BCB555E417CEFC3" target="_blank"> <a href="https://exolix.com/?ref=0FAB49E2F09EFBCB0BCB555E417CEFC3" target="_blank">
<img src="../../../static/img/Exolix_square.png" width="250" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;"> <img src="../../../static/img/Exolix_square.png" width="100" height="100" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;">
</a> </a>
</div> </div>
</div>
</div>
<div class="col-lg-6">
<div class="row">
<div class="col"> <div class="col" style="display:inline-block;min-width: 110px;max-width: 110px;padding:5px 5px;">
<a href="https://letsexchange.io/?ref_id=c2R7XSAe5C72L6uA" target="_blank"> <a href="https://letsexchange.io/?ref_id=c2R7XSAe5C72L6uA" target="_blank">
<img src="../../../static/img/LetsExchange_square.png" width="250" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;"> <img src="../../../static/img/LetsExchange_square.png" width="100" height="100" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;">
</a> </a>
</div> </div>
<div class="col"> <div class="col" style="display:inline-block;min-width: 110px;max-width: 110px;padding:5px 5px;">
<a href="https://stealthex.io/?ref=4i60ofmkz4o" target="_blank"> <a href="https://stealthex.io/?ref=4i60ofmkz4o" target="_blank">
<img src="../../../static/img/Stealthex_square.png" width="250" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;"> <img src="../../../static/img/Stealthex_square.png" width="100" height="100" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;">
</a> </a>
</div> </div>
<div class="col"> <div class="col" style="display:inline-block;min-width: 110px;max-width: 110px;padding:5px 5px;">
<a href="https://monerotopia.com/" target="_blank"> <a href="https://monerotopia.com/" target="_blank">
<img src="../../../static/img/monerotopia.png" width="250" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;"> <img src="../../../static/img/monerotopia.png" width="100" height="100" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;">
</a> </a>
</div> </div>
<div class="col" style="display:inline-block;min-width: 110px;max-width: 110px;padding:5px 5px;">
<a href="https://trocador.app/" target="_blank">
<img src="../../../static/img/Trocador_square.png" width="100" height="100" class="img-fluid" alt="" style="margin-top: 20px; border-radius: 20px;">
</a>
</div> </div>
</div> </div>
</div> </div>
@ -573,3 +574,4 @@
<!-- End #main --> <!-- End #main -->
{% endblock %} {% endblock %}

View file

@ -9,26 +9,6 @@
<!-- Content Wrapper --> <!-- Content Wrapper -->
<div id="content-wrapper" style="background-color:rgb(48, 44, 41)"> <div id="content-wrapper" style="background-color:rgb(48, 44, 41)">
<!-- Content Row -->
<div class="row" style="height: 92%; margin: 10px 10px 10px 10px;">
<div class="card" id="graph1" style="width: 100%; height: 100%;">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between text-white">
<h6 class="m-0 text-light">
Total Number of Reddit Subscribers for Bitcoin and CryptoCurrency
</h6>
<div class="dropdown no-arrow">
<a data-toggle="modal" href="#" class="link_graph" data-target="#id_Modal">
About this chart?
</a>
</div>
</div>
<div class="card-body" style="width: 100%; height: 100%; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;">
<div id="graph" style="width: 100%; height: 100%; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;"></div>
</div>
</div>
</div>
<!-- Content Row --> <!-- Content Row -->
<div class="row" style="height: 92%; margin: 10px 10px 10px 10px;"> <div class="row" style="height: 92%; margin: 10px 10px 10px 10px;">
<div class="card" id="graph_2" style="width: 100%; height: 100%;"> <div class="card" id="graph_2" style="width: 100%; height: 100%;">
@ -313,11 +293,9 @@
} }
env_size = findBootstrapEnvironment(); env_size = findBootstrapEnvironment();
if (env_size == "xs") { if (env_size == "xs") {
Plotly.newPlot('graph', data_mobile, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
Plotly.newPlot('graph2', data_mobile_2, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false}); Plotly.newPlot('graph2', data_mobile_2, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
} }
else { else {
Plotly.newPlot('graph', data, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
Plotly.newPlot('graph2', data_2, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false}); Plotly.newPlot('graph2', data_2, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
} }
</script> </script>

View file

@ -9,26 +9,6 @@
<!-- Content Wrapper --> <!-- Content Wrapper -->
<div id="content-wrapper" style="background-color:rgb(48, 44, 41)"> <div id="content-wrapper" style="background-color:rgb(48, 44, 41)">
<!-- Content Row -->
<div class="row" style="height: 92%; margin: 10px 10px 10px 10px;">
<div class="card" id="graph1" style="width: 100%; height: 100%;">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between text-white">
<h6 class="m-0 text-light">
Reddit Subscribers of /CryptoCurrency as a Percentage of /Bitcoin
</h6>
<div class="dropdown no-arrow">
<a data-toggle="modal" href="#" class="link_graph" data-target="#id_Modal">
About this chart?
</a>
</div>
</div>
<div class="card-body" style="width: 100%; height: 100%; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;">
<div id="graph" style="width: 100%; height: 100%; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;"></div>
</div>
</div>
</div>
<!-- Content Row --> <!-- Content Row -->
<div class="row" style="height: 92%; margin: 10px 10px 10px 10px;"> <div class="row" style="height: 92%; margin: 10px 10px 10px 10px;">
<div class="card" id="graph_2" style="width: 100%; height: 100%;"> <div class="card" id="graph_2" style="width: 100%; height: 100%;">
@ -291,11 +271,9 @@ var data1 = {
} }
env_size = findBootstrapEnvironment(); env_size = findBootstrapEnvironment();
if (env_size == "xs") { if (env_size == "xs") {
Plotly.newPlot('graph', data_mobile, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
Plotly.newPlot('graph2', data_mobile_2, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false}); Plotly.newPlot('graph2', data_mobile_2, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
} }
else { else {
Plotly.newPlot('graph', data, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
Plotly.newPlot('graph2', data_2, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false}); Plotly.newPlot('graph2', data_2, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
} }
</script> </script>

View file

@ -26,7 +26,6 @@ urlpatterns = [
path('extracoins/', views.extracoins, name='extracoins'), path('extracoins/', views.extracoins, name='extracoins'),
path('sfmodel/', views.sfmodel, name='sfmodel'), path('sfmodel/', views.sfmodel, name='sfmodel'),
path('sfmodellin/', views.sfmodellin, name='sfmodellin'), path('sfmodellin/', views.sfmodellin, name='sfmodellin'),
path('sfmodel/', views.sfmodel, name='sfmodel'),
path('sfmultiple/', views.sfmultiple, name='sfmultiple'), path('sfmultiple/', views.sfmultiple, name='sfmultiple'),
path('about/', views.about, name='about'), path('about/', views.about, name='about'),
path('compinflation/', views.compinflation, name='compinflation'), path('compinflation/', views.compinflation, name='compinflation'),

View file

@ -178,6 +178,9 @@ def get_history(request, symbol, start_time=None, end_time=None):
coin.inflation = inflation coin.inflation = inflation
coin.stocktoflow = stocktoflow coin.stocktoflow = stocktoflow
try: try:
if float(item['SplyCur']) < 18000000:
coin.supply = float(item['SplyCur']) + 497108
else:
coin.supply = float(item['SplyCur']) coin.supply = float(item['SplyCur'])
supply = coin.supply supply = coin.supply
except: except:
@ -215,7 +218,7 @@ def get_history(request, symbol, start_time=None, end_time=None):
coin.save() coin.save()
count += 1 count += 1
print(str(symbol) + ' ' + str(coin.date)) print(str(symbol) + ' ' + str(coin.date) + ' ' + str(item['SplyCur']))
except: except:
pass pass
@ -1361,6 +1364,16 @@ 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')
count = 0
for coin in coins:
count += 1
if count< 200:
if coin.supply < 18000000:
coin.supply += 499736
print(coin.date)
coin.save()
coin = list(Coin.objects.order_by('-date'))[0] coin = list(Coin.objects.order_by('-date'))[0]
if not(coin): if not(coin):
message = 'Website under maintenance. Check back in a few minutes' message = 'Website under maintenance. Check back in a few minutes'
@ -1453,7 +1466,8 @@ async def index(request):
coin_xmr = list(Coin.objects.filter(name='xmr').order_by('-date'))[0] coin_xmr = list(Coin.objects.filter(name='xmr').order_by('-date'))[0]
if update_xmr: if update_xmr:
await asynchronous.update_xmr_data(yesterday, coin_xmr) get_history(request, 'xmr', yesterday, yesterday)
#await asynchronous.update_xmr_data(yesterday, coin_xmr)
if update_socials: if update_socials:
synchronous.check_new_social('Bitcoin') synchronous.check_new_social('Bitcoin')
@ -1754,9 +1768,14 @@ def social4(request):
last_xmr = '' last_xmr = ''
newcomers_xmr.append(last_xmr) newcomers_xmr.append(last_xmr)
try:
last_xmr = locale.format('%.0f', last_xmr, grouping=True) last_xmr = locale.format('%.0f', last_xmr, grouping=True)
last_btc = locale.format('%.0f', last_btc, grouping=True) last_btc = locale.format('%.0f', last_btc, grouping=True)
last_crypto = locale.format('%.0f', last_crypto, grouping=True) last_crypto = locale.format('%.0f', last_crypto, grouping=True)
except:
last_xmr = 0
last_btc = 0
last_crypto = 0
context = {'dates': dates, 'speed_xmr': speed_xmr, 'speed_crypto': speed_crypto, 'speed_btc': speed_btc, 'newcomers_xmr': newcomers_xmr, 'newcomers_btc': newcomers_btc, 'newcomers_crypto': newcomers_crypto, 'last_xmr': last_xmr, 'last_btc': last_btc, 'last_crypto': last_crypto} context = {'dates': dates, 'speed_xmr': speed_xmr, 'speed_crypto': speed_crypto, 'speed_btc': speed_btc, 'newcomers_xmr': newcomers_xmr, 'newcomers_btc': newcomers_btc, 'newcomers_crypto': newcomers_crypto, 'last_xmr': last_xmr, 'last_btc': last_btc, 'last_crypto': last_crypto}
return render(request, 'charts/social4.html', context) return render(request, 'charts/social4.html', context)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 133 KiB