Skip to content

Commit 4e4d07f

Browse files
committed
Merge opentimestamps#40: various dashboard fixes
b682fef fix english (Vincent Cloutier) dbccd73 various dashboard fixes (Vincent Cloutier) Pull request description: Tree-SHA512: 529f03d700a37a63fd3ba6e4eea8d54995de4d759181c2bbd0d251ec24415fa95fa14dae6b5254df144ea083925777896b361805c3d96bf55d523d39cf0eddaa
2 parents 3af9e46 + b682fef commit 4e4d07f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

otsserver/rpc.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,18 @@ def do_GET(self):
157157
# need to investigate further, but this seems to work.
158158
str_wallet_balance = str(proxy._call("getbalance"))
159159

160-
transactions = proxy._call("listtransactions", "", 50)
160+
transactions = proxy._call("listtransactions", "", 1000)
161161
# We want only the confirmed txs containing an OP_RETURN, from most to least recent
162162
transactions = list(filter(lambda x: x["confirmations"] > 0 and x["amount"] == 0, transactions))
163163
a_week_ago = (datetime.date.today() - datetime.timedelta(days=7)).timetuple()
164164
a_week_ago_posix = time.mktime(a_week_ago)
165165
transactions_in_last_week = list(filter(lambda x: x["time"] > a_week_ago_posix, transactions))
166166
fees_in_last_week = reduce(lambda a,b: a-b["fee"], transactions_in_last_week, 0)
167-
time_between_transactions = round(168 / len(transactions_in_last_week)) # in hours based on 168 hours in a week
167+
try:
168+
time_between_transactions = str(round(168 / len(transactions_in_last_week))) # in hours based on 168 hours in a week
169+
time_between_transactions += " hour(s)"
170+
except ZeroDivisionError:
171+
time_between_transactions = "N/A"
168172
transactions.sort(key=lambda x: x["confirmations"])
169173
homepage_template = """<html>
170174
<head>
@@ -186,7 +190,7 @@ def do_GET(self):
186190
This address changes after every donation.
187191
</p>
188192
<p>
189-
Average time between transactions in the last week: {{ time_between_transactions }} hour(s)</br>
193+
Average time between transactions in the last week: {{ time_between_transactions }} </br>
190194
Fees used in the last week: {{ fees_in_last_week }} BTC</br>
191195
Latest transactions: </br>
192196
{{#transactions}}

0 commit comments

Comments
 (0)