fixing issues

This commit is contained in:
anon 2022-06-20 00:10:53 -03:00
parent 61b3535296
commit 93424cffe0
4 changed files with 409 additions and 23 deletions

View file

@ -160,7 +160,7 @@
<a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseTransactions" <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseTransactions"
aria-expanded="true" aria-controls="collapseTransactions"> aria-expanded="true" aria-controls="collapseTransactions">
<i class="fas fa-exchange-alt"></i> <i class="fas fa-exchange-alt"></i>
<span>Transactions (7)</span> <span>Transactions (8)</span>
</a> </a>
<div id="collapseTransactions" class="collapse" aria-labelledby="headingTransactions" <div id="collapseTransactions" class="collapse" aria-labelledby="headingTransactions"
data-parent="#accordionSidebar"> data-parent="#accordionSidebar">
@ -168,6 +168,7 @@
<h6 class="collapse-header text-dark">Charts:</h6> <h6 class="collapse-header text-dark">Charts:</h6>
<a class="collapse-item" href="{% url 'monerojnet:translin' %}">Transaction Count (Lin.)</a> <a class="collapse-item" href="{% url 'monerojnet:translin' %}">Transaction Count (Lin.)</a>
<a class="collapse-item" href="{% url 'monerojnet:translog' %}">Transaction Count (Log.)</a> <a class="collapse-item" href="{% url 'monerojnet:translog' %}">Transaction Count (Log.)</a>
<a class="collapse-item" href="{% url 'monerojnet:transmonth' %}">Monthly Transactions (Lin.)</a>
<a class="collapse-item" href="{% url 'monerojnet:transcost' %}">Transaction Cost ($)</a> <a class="collapse-item" href="{% url 'monerojnet:transcost' %}">Transaction Cost ($)</a>
<a class="collapse-item" href="{% url 'monerojnet:transcostntv' %}">Transaction Cost (Ntv.)</a> <a class="collapse-item" href="{% url 'monerojnet:transcostntv' %}">Transaction Cost (Ntv.)</a>
<a class="collapse-item" href="{% url 'monerojnet:percentage' %}">Transaction Percentage</a> <a class="collapse-item" href="{% url 'monerojnet:percentage' %}">Transaction Percentage</a>

View file

@ -0,0 +1,336 @@
{% extends 'monerojnet/base.html' %}
{% block content %}
<!-- Content Wrapper -->
<div id="content-wrapper" style="background-color:rgb(48, 44, 41)">
<!-- Main Content -->
<div id="content">
<!-- Begin Page Content -->
<div class="container-fluid"><br>
<div class="row">
<div class="col-xl-12 col-lg-12">
<div class="card" id="graph1">
<div
class="card-header py-3 d-flex flex-row align-items-center justify-content-between text-white">
<h6 class="m-0 text-light">Monthly Transactions</h6>
<div class="dropdown no-arrow">
<a class="dropdown-toggle" href="#" role="button"
onclick="$('#graph1').toggleClass('fullscreen');window.dispatchEvent(new Event('resize'));">
<i class="fas fa-arrows-alt fa-sm fa-fw text-gray-400"></i>
</a>
</div>
</div>
<div class="card-body pb-0 pt-0 pl-0 pr-0" style="height: 100px;">
<div id="graph" style="height: 100%; width:100%;"></div>
</div>
</div>
<br>
</div>
</div>
<!-- Content Row -->
<div class="row">
<!-- Card -->
<div class="col-xl-6 col-md-6 mb-4">
<div class="card border-left-new h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">
Monthly Transactions</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ now_transactions }}</div>
</div>
<div class="col-auto">
<i class="fab fa-monero fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Card -->
<div class="col-xl-6 col-md-6 mb-4">
<div class="card border-left-new h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">
Highest Number of Transactions</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ maximum }}</div>
</div>
<div class="col-auto">
<i class="fas fa-rocket fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Content Row -->
<div class="row">
<div class="col-xl-11 col-md-6 mb-4">
<div class="alert alert-dark" role="alert">
Not financial advice.
For information about the chart, click the button >
</div>
</div>
<div class="col-xl-1">
<button type="button" class="btn btn-dark btn-block" data-toggle="modal" href="#"
data-target="#id_Modal">
<div class="col-auto">
<i class="fa fa-info-circle fa-2x "></i>
</div>
</button>
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
</div>
<!-- End of Content Wrapper -->
<!-- Modal -->
<div class="modal fade" id="id_Modal" tabindex="-1" role="dialog" aria-labelledby="Modal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="Modal">Help about the chart</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Cancelar">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Number of monthly Monero transactions.<br>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Fim do Modal -->
<!-- Page level plugins -->
<script>
var data2 = {
type: "bar",
name: 'Number of Transactions (XMR)',
x: {{ dates|safe }},
y: {{ transactions|safe }},
hovertemplate: '%{y}',
line: {
color: '#dd1d1d'
,width: 3
},
textposition: 'inside',
marker: {
color: '#dd1d1d',
opacity: 0.9,
line: {
color: '#fd4d4d',
width: 1
}
}
};
var data2_mobile = {
type: "bar",
name: 'Number of Transactions (XMR)',
x: {{ dates|safe }},
y: {{ transactions|safe }},
hovertemplate: '%{y}',
line: {
color: '#dd1d1d'
,width: 3
},
textposition: 'inside',
marker: {
color: '#dd1d1d',
opacity: 0.9,
line: {
color: '#fd4d4d',
width: 1
}
}
};
var data = [data2];
var data_mobile = [data2_mobile];
var layout = {
plot_bgcolor:"#252221",
paper_bgcolor:"#252221",
annotations: [
{
xref: 'paper',
yref: 'paper',
x: 0.02,
xanchor: 'auto',
y: 0.98,
yanchor: 'auto',
text: 'Moneroj<br>https://www.moneroj.net',
showarrow: false,
borderwidth: 1,
bordercolor: '#5f5f5f',
bgcolor: '#333333',
borderpad: 5,
align: 'center',
font: {
color: "white",
size: 12
}
}],
separators: ",.",
legend: {
x: 0.02,
y: 0.50,
bgcolor: '#333333',
bordercolor: '#5f5f5f',
borderwidth: 1,
font: {
color: 'white',
size: 12
},
traceorder: 'normal',
xanchor: 'auto',
yanchor: 'auto'
},
hoverlabel: {
namelength: -1
},
yaxis: {
type: "linear",
title: {
text: 'Number of Monthly Transactions',
font: {
size: 20,
color: 'white'
}
},
tickformat :",.0f"
,nticks: 10
,tickfont: {
color: "#ffffff"
,size: 12
}
,gridcolor: "#333333"
},
xaxis: {
hoverformat: "%Y-%m",
showgrid: true,
type: 'date',
nticks: 10
,tickfont: {
color: "#dddddd"
,size: 13
}
,gridcolor: "#333333"
,range: ['2014-05-01', '2023-06-01']
,zeroline: true
},
margin: {
l: 120,
r: 60,
b: 35,
t: 10,
pad: 4
}
};
var layout_mobile = {
plot_bgcolor:"black",
paper_bgcolor:"black",
separators: ",.",
hoverlabel: {
namelength: -1
},
legend: {
x: 0.02,
y: 0.98,
bgcolor: '#000000',
bordercolor: '#5f5f5f',
borderwidth: 1,
font: {
color: 'white',
size: 5
},
traceorder: 'normal',
xanchor: 'auto',
yanchor: 'auto'
},
showlegend: false,
yaxis: {
type: "linear",
tickformat :",.0f"
,nticks: 10
,tickfont: {
color: "#ffffff"
,size: 7
}
,gridcolor: "#444444"
},
xaxis: {
hoverformat: "%Y-%m",
showgrid: true,
type: 'date',
nticks: 10
,tickfont: {
color: "#dddddd"
,size: 13
}
,gridcolor: "#333333"
,range: ['2014-05-01', '2023-06-01']
,zeroline: true
},
margin: {
l: 40,
r: 0,
b: 35,
t: 10,
pad: 0
}
};
function findBootstrapEnvironment() {
let envs = ['xs', 'sm', 'md', 'lg', 'xl'];
let el = document.createElement('div');
document.body.appendChild(el);
let curEnv = envs.shift();
for (let env of envs.reverse()) {
el.classList.add(`d-${env}-none`);
if (window.getComputedStyle(el).display === 'none') {
curEnv = env;
break;
}
}
document.body.removeChild(el);
return curEnv;
}
env_size = findBootstrapEnvironment();
if (env_size == "xs") {
document.getElementById("graph1").style.height="350px";
Plotly.newPlot('graph', data_mobile, layout_mobile, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
}
else {
document.getElementById("graph1").style.height="700px";
Plotly.newPlot('graph', data, layout, {responsive: true, modeBarButtonsToRemove: ['toImage', 'hoverCompareCartesian', 'hoverClosest2d', 'toggleSpikelines', 'lasso2d', 'select2d', 'hoverClosestCartesian'], displaylogo: false});
}
</script>
{% endblock %}

View file

@ -79,6 +79,7 @@ urlpatterns = [
path('transactionsize/', views.transactionsize, name='transactionsize'), path('transactionsize/', views.transactionsize, name='transactionsize'),
path('blockchainsize/', views.blockchainsize, name='blockchainsize'), path('blockchainsize/', views.blockchainsize, name='blockchainsize'),
path('difficulty/', views.difficulty, name='difficulty'), path('difficulty/', views.difficulty, name='difficulty'),
path('transmonth/', views.transmonth, name='transmonth'),
# URLs to useful functions on monerojnet/views.py # URLs to useful functions on monerojnet/views.py
# Only admins can use these # Only admins can use these

View file

@ -286,6 +286,7 @@ def populate_database(request):
timevar = 1283 timevar = 1283
v0 = 0.002 v0 = 0.002
delta = (0.015 - 0.002)/(6*365) delta = (0.015 - 0.002)/(6*365)
previous_supply = 0
supply = 0 supply = 0
sf_aux = 0 sf_aux = 0
count_aux = 0 count_aux = 0
@ -299,7 +300,10 @@ def populate_database(request):
coin.stocktoflow = sf_aux coin.stocktoflow = sf_aux
sf_aux = coin.stocktoflow sf_aux = coin.stocktoflow
if coin.supply > 0:
supply = int(coin.supply)*10**12 supply = int(coin.supply)*10**12
else:
supply = previous_supply
count += 1 count += 1
count_aux += 1 count_aux += 1
@ -346,6 +350,7 @@ def populate_database(request):
data.greyline = actualprice data.greyline = actualprice
else: else:
data.greyline = 0 data.greyline = 0
previous_supply = supply
data.save() data.save()
count_aux = 0 count_aux = 0
@ -954,6 +959,7 @@ def update_database(date_from=None, date_to=None):
date_to = date.today() date_to = date.today()
date_from = date_to - timedelta(5) date_from = date_to - timedelta(5)
else: else:
print(str(date_from) + ' to ' + str(date_to))
date_from = datetime.datetime.strptime(date_from, '%Y-%m-%d') date_from = datetime.datetime.strptime(date_from, '%Y-%m-%d')
date_to = datetime.datetime.strptime(date_to, '%Y-%m-%d') date_to = datetime.datetime.strptime(date_to, '%Y-%m-%d')
@ -1194,9 +1200,7 @@ def index(request):
if rank.date < date.today(): if rank.date < date.today():
data = update_rank() data = update_rank()
dominance = list(Dominance.objects.order_by('-date'))[0] update_dominance(data)
if dominance.date < date.today():
data = update_dominance(data)
coin = list(Coin.objects.filter(name=symbol).order_by('-date'))[0] coin = list(Coin.objects.filter(name=symbol).order_by('-date'))[0]
if coin: if coin:
@ -2312,7 +2316,7 @@ def inflationreturn(request):
coins = Coin.objects.order_by('date').filter(name='xmr') coins = Coin.objects.order_by('date').filter(name='xmr')
for coin in coins: for coin in coins:
count += 1 count += 1
if coin.priceusd and count > 30: if coin.priceusd and count > 30 and coin.inflation > 0:
now_xmr = coin.priceusd/5.01 now_xmr = coin.priceusd/5.01
#correcao de um erro nos dados #correcao de um erro nos dados
if 100/coin.inflation > 110 and now_xmr < 10: if 100/coin.inflation > 110 and now_xmr < 10:
@ -2328,7 +2332,7 @@ def inflationreturn(request):
coins = Coin.objects.order_by('date').filter(name='dash') coins = Coin.objects.order_by('date').filter(name='dash')
for coin in coins: for coin in coins:
count += 1 count += 1
if coin.priceusd and count > 130: if coin.priceusd and count > 130 and coin.inflation > 0:
now_dash = coin.priceusd/14.7 now_dash = coin.priceusd/14.7
dash.append(now_dash) dash.append(now_dash)
inflation_dash.append(100/coin.inflation) inflation_dash.append(100/coin.inflation)
@ -2337,7 +2341,7 @@ def inflationreturn(request):
coins = Coin.objects.order_by('date').filter(name='grin') coins = Coin.objects.order_by('date').filter(name='grin')
for coin in coins: for coin in coins:
count += 1 count += 1
if coin.priceusd and count > 155: if coin.priceusd and count > 155 and coin.inflation > 0:
now_grin = coin.priceusd/6.37 now_grin = coin.priceusd/6.37
grin.append(now_grin) grin.append(now_grin)
inflation_grin.append(100/coin.inflation) inflation_grin.append(100/coin.inflation)
@ -2346,7 +2350,7 @@ def inflationreturn(request):
coins = Coin.objects.order_by('date').filter(name='zec') coins = Coin.objects.order_by('date').filter(name='zec')
for coin in coins: for coin in coins:
count += 1 count += 1
if coin.priceusd and count > 434: if coin.priceusd and count > 434 and coin.inflation > 0:
now_zcash = coin.priceusd/750 now_zcash = coin.priceusd/750
zcash.append(now_zcash) zcash.append(now_zcash)
inflation_zcash.append(100/coin.inflation) inflation_zcash.append(100/coin.inflation)
@ -2355,7 +2359,7 @@ def inflationreturn(request):
coins = Coin.objects.order_by('date').filter(name='btc') coins = Coin.objects.order_by('date').filter(name='btc')
for coin in coins: for coin in coins:
count += 1 count += 1
if coin.priceusd and count > 325: if coin.priceusd and count > 325 and coin.inflation > 0:
now_btc = coin.priceusd/30 now_btc = coin.priceusd/30
btc.append(now_btc) btc.append(now_btc)
inflation_btc.append(100/coin.inflation) inflation_btc.append(100/coin.inflation)
@ -2387,12 +2391,12 @@ def bitcoin(request):
coins_btc = Coin.objects.order_by('date').filter(name='btc') coins_btc = Coin.objects.order_by('date').filter(name='btc')
for coin_btc in coins_btc: for coin_btc in coins_btc:
if coin_btc.priceusd: if coin_btc.priceusd:
if count1 > 325: #450 if count1 > 890: #450
btc.append(coin_btc.priceusd/30) btc.append(coin_btc.priceusd/30)
now_btc = coin_btc.priceusd/30 now_btc = coin_btc.priceusd/30
dates.append(count1) dates.append(count1)
count1 += 1 #1.4 count1 += 1 #1.4
elif count1 <= 325: #450 elif count1 <= 890: #450
continue continue
else: else:
btc.append('') btc.append('')
@ -2404,7 +2408,7 @@ def bitcoin(request):
if count3 > 30: if count3 > 30:
xmr3.append(coin_xmr.priceusd/5.01) xmr3.append(coin_xmr.priceusd/5.01)
dates4.append(count3) dates4.append(count3)
count3 += 0.82 count3 += 0.92
elif count3 <= 30: elif count3 <= 30:
continue continue
else: else:
@ -2472,6 +2476,44 @@ def translin(request):
context = {'transactions': transactions, 'dates': dates, 'maximum': maximum, 'now_transactions': now_transactions, 'pricexmr': pricexmr} context = {'transactions': transactions, 'dates': dates, 'maximum': maximum, 'now_transactions': now_transactions, 'pricexmr': pricexmr}
return render(request, 'monerojnet/translin.html', context) return render(request, 'monerojnet/translin.html', context)
def transmonth(request):
dt = datetime.datetime.now(timezone.utc).timestamp()
symbol = 'xmr'
transactions = []
pricexmr = []
dates = []
now_transactions = 0
maximum = 0
month_previous = '2014-01'
month = 0
total = 0
coins = Coin.objects.order_by('date').filter(name=symbol)
for coin in coins:
aux = str(coin.date)
month = aux.split("-")[0] + '-' + aux.split("-")[1]
if month != month_previous:
dates.append(month_previous)
transactions.append(total)
if total > maximum:
maximum = total
total = 0
month_previous = month
if coin.transactions > 0:
total += coin.transactions
now_transactions = int(total)
maximum = int(maximum)
now_transactions = locale.format('%.0f', now_transactions, grouping=True)
maximum = locale.format('%.0f', maximum, grouping=True)
dt = 'transmonth.html ' + locale.format('%.2f', datetime.datetime.now(timezone.utc).timestamp() - dt, grouping=True)+' seconds'
print(dt)
context = {'transactions': transactions, 'dates': dates, 'maximum': maximum, 'now_transactions': now_transactions, 'pricexmr': pricexmr}
return render(request, 'monerojnet/transmonth.html', context)
def percentage(request): def percentage(request):
dt = datetime.datetime.now(timezone.utc).timestamp() dt = datetime.datetime.now(timezone.utc).timestamp()
data = DailyData.objects.order_by('date') data = DailyData.objects.order_by('date')
@ -2548,6 +2590,8 @@ def hashrate(request):
if coin.hashrate > 0: if coin.hashrate > 0:
now_hashrate = coin.hashrate now_hashrate = coin.hashrate
hashrate.append(coin.hashrate) hashrate.append(coin.hashrate)
else:
hashrate.append('')
now_hashrate = locale.format('%.0f', now_hashrate, grouping=True) now_hashrate = locale.format('%.0f', now_hashrate, grouping=True)
@ -2611,7 +2655,7 @@ def hashvsprice(request):
if count > 55: if count > 55:
coin.date = datetime.datetime.strftime(coin.date, '%Y-%m-%d') coin.date = datetime.datetime.strftime(coin.date, '%Y-%m-%d')
dates.append(coin.date) dates.append(coin.date)
if coin.priceusd > 0: if coin.priceusd > 0 and coin.hashrate:
now_hashrate = coin.hashrate now_hashrate = coin.hashrate
now_priceusd = coin.priceusd now_priceusd = coin.priceusd
now_pricebtc = coin.pricebtc now_pricebtc = coin.pricebtc
@ -3195,9 +3239,13 @@ def sfmodel(request):
update = True update = True
symbol = 'xmr' symbol = 'xmr'
coins = Coin.objects.filter(name=symbol).order_by('date')
for coin in coins:
print(coin.date)
today = datetime.datetime.strftime(date.today(), '%Y-%m-%d')
yesterday = date.today() - timedelta(1) yesterday = date.today() - timedelta(1)
start_time = datetime.datetime.strftime(yesterday, '%Y-%m-%d') start_time = datetime.datetime.strftime(date.today() - timedelta(7), '%Y-%m-%d')
try: try:
coin = Coin.objects.filter(name=symbol).get(date=yesterday) coin = Coin.objects.filter(name=symbol).get(date=yesterday)
if coin: if coin:
@ -3215,12 +3263,12 @@ def sfmodel(request):
update = True update = True
if update: if update:
#print('social') print('social')
check_new_social('Bitcoin') check_new_social('Bitcoin')
check_new_social('Monero') check_new_social('Monero')
check_new_social('CryptoCurrency') check_new_social('CryptoCurrency')
#print('metrics') print('metrics')
with open("settings.json") as file: with open("settings.json") as file:
data = json.load(file) data = json.load(file)
file.close() file.close()
@ -3241,9 +3289,9 @@ def sfmodel(request):
url = data["metrics_provider"][0]["metrics_url"] + symbol + data["metrics_provider"][0]["metrics"] + '&start_time=' + start_time url = data["metrics_provider"][0]["metrics_url"] + symbol + data["metrics_provider"][0]["metrics"] + '&start_time=' + start_time
get_latest_metrics(symbol, url) get_latest_metrics(symbol, url)
#print('updating database') print('updating database')
update_database() update_database(start_time, today)
#print('done') print('done')
dates = [] dates = []
stock_to_flow = [] stock_to_flow = []