yearly details
This commit is contained in:
parent
b931297a06
commit
0afa789e6c
|
|
@ -46,6 +46,15 @@ cursor.execute("""SELECT strftime('%Y-%m', timestamp, 'unixepoch', '-3 hours') A
|
||||||
ORDER BY year_month_utc3;""")
|
ORDER BY year_month_utc3;""")
|
||||||
last_n_months_rows = cursor.fetchall()
|
last_n_months_rows = cursor.fetchall()
|
||||||
|
|
||||||
|
#Last n months query
|
||||||
|
cursor.execute("""SELECT strftime('%Y', timestamp, 'unixepoch', '-3 hours') AS year_utc3,
|
||||||
|
SUM(amount) AS total_amount
|
||||||
|
FROM profits_table
|
||||||
|
WHERE strftime('%s', 'now') - timestamp <= 60 * 30 * 24 * 60 * 60 -- 48 months in seconds
|
||||||
|
GROUP BY year_utc3
|
||||||
|
ORDER BY year_utc3;""")
|
||||||
|
last_n_years_rows = cursor.fetchall()
|
||||||
|
|
||||||
#Yearly totals
|
#Yearly totals
|
||||||
cursor.execute("""SELECT strftime('%Y', timestamp, 'unixepoch', '-3 hours') AS year_utc3,
|
cursor.execute("""SELECT strftime('%Y', timestamp, 'unixepoch', '-3 hours') AS year_utc3,
|
||||||
SUM(amount) AS total_amount
|
SUM(amount) AS total_amount
|
||||||
|
|
@ -66,6 +75,12 @@ print("-"*line_width)
|
||||||
for row in last_n_months_rows[1:]:
|
for row in last_n_months_rows[1:]:
|
||||||
print(f"{row[0]}: {round(row[1],2)}")
|
print(f"{row[0]}: {round(row[1],2)}")
|
||||||
print("-"*line_width)
|
print("-"*line_width)
|
||||||
|
print("Last 5 years:")
|
||||||
|
print("-"*line_width)
|
||||||
|
for row in last_n_years_rows:
|
||||||
|
print(f"{row[0]}: {round(row[1],2)}")
|
||||||
|
print("-"*line_width)
|
||||||
|
|
||||||
print(f"Last 30 days average: {round(last_30_days[0][1]/30,2)}")
|
print(f"Last 30 days average: {round(last_30_days[0][1]/30,2)}")
|
||||||
print(f"Last 7 days average: {round(last_7_days[0][1]/7,2)}")
|
print(f"Last 7 days average: {round(last_7_days[0][1]/7,2)}")
|
||||||
cursor.execute("""SELECT strftime('%Y-%m-%d', timestamp, 'unixepoch', '-3 hours') AS day_utc3,
|
cursor.execute("""SELECT strftime('%Y-%m-%d', timestamp, 'unixepoch', '-3 hours') AS day_utc3,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue