mirror of
https://github.com/NovaOSS/nova-web.git
synced 2024-11-25 16:33:57 +01:00
Fixes
This commit is contained in:
parent
b068225c72
commit
a1543f9a4f
7
requirements.txt
Normal file
7
requirements.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
flask
|
||||||
|
pandas
|
||||||
|
cherrypy
|
||||||
|
requests
|
||||||
|
werkzeug
|
||||||
|
python-dotenv
|
||||||
|
requests-oauthlib
|
|
@ -36,17 +36,37 @@ def register(app):
|
||||||
donations = data['donations']
|
donations = data['donations']
|
||||||
expenses = data['expenses']
|
expenses = data['expenses']
|
||||||
|
|
||||||
|
try:
|
||||||
|
avg = round(sum([i['amount_usd'] for i in donations]) / len(donations), 2)
|
||||||
|
except ZeroDivisionError:
|
||||||
|
avg = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
most_donation = max(donations, key=lambda x: x['amount_usd'])['currency']
|
||||||
|
except ValueError:
|
||||||
|
most_donation = '?'
|
||||||
|
|
||||||
|
try:
|
||||||
|
most_expense = max(expenses, key=lambda x: x['amount_usd'])['currency']
|
||||||
|
except ValueError:
|
||||||
|
most_expense = '?'
|
||||||
|
|
||||||
|
try:
|
||||||
|
donations_max = round(max([i['amount_usd'] for i in donations]))
|
||||||
|
except ValueError:
|
||||||
|
donations_max = 0
|
||||||
|
|
||||||
finances = {
|
finances = {
|
||||||
'last_update': data['timestamp'],
|
'last_update': data['timestamp'],
|
||||||
'donations_total': round(sum([i['amount_usd'] for i in donations])),
|
'donations_total': round(sum([i['amount_usd'] for i in donations])),
|
||||||
'donations_num': len(donations),
|
'donations_num': len(donations),
|
||||||
'donations_avg': round(sum([i['amount_usd'] for i in donations]) / len(donations), 2),
|
'donations_avg': avg,
|
||||||
'donations_max': round(max([i['amount_usd'] for i in donations])),
|
'donations_max': donations_max,
|
||||||
'most_used_donation_currency': max(donations, key=lambda x: x['amount_usd'])['currency'],
|
'most_used_donation_currency': most_donation,
|
||||||
|
|
||||||
'expenses_total': round(sum([i['amount_usd'] for i in expenses])),
|
'expenses_total': round(sum([i['amount_usd'] for i in expenses])),
|
||||||
'expenses_wages': round(sum([i['amount_usd'] for i in expenses if i['type'] == 'wage'])),
|
'expenses_wages': round(sum([i['amount_usd'] for i in expenses if i['type'] == 'wage'])),
|
||||||
'most_used_expense_currency': max(expenses, key=lambda x: x['amount_usd'])['currency'],
|
'most_used_expense_currency': most_expense,
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction_table = []
|
transaction_table = []
|
||||||
|
|
|
@ -19,8 +19,8 @@ def register(app):
|
||||||
emoji = random.choice(open('config/emojis.txt', encoding='utf8').read())
|
emoji = random.choice(open('config/emojis.txt', encoding='utf8').read())
|
||||||
|
|
||||||
if not os.path.exists('data/tos.json'):
|
if not os.path.exists('data/tos.json'):
|
||||||
|
os.makedirs('data', exist_ok=True)
|
||||||
open('data/tos.json', 'w', encoding='utf8').write('{}')
|
open('data/tos.json', 'w', encoding='utf8').write('{}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = ujson.load(open('data/tos.json', encoding='utf8'))
|
data = ujson.load(open('data/tos.json', encoding='utf8'))
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
|
|
Loading…
Reference in a new issue