minor fixes
This commit is contained in:
parent
9a77c1a36f
commit
abd7d1eb4b
|
|
@ -181,13 +181,13 @@ def query_total_profit(pair=None, start_date=0):
|
||||||
query = "SELECT SUM(amount) AS total_profit FROM profits_table WHERE timestamp >= ?"
|
query = "SELECT SUM(amount) AS total_profit FROM profits_table WHERE timestamp >= ?"
|
||||||
params = (start_date,)
|
params = (start_date,)
|
||||||
else:
|
else:
|
||||||
query = """SELECT pair, SUM(amount) AS total_profit FROM profits_table WHERE timestamp >= ? AND pair = ?"""
|
query = """SELECT SUM(amount) AS total_profit FROM profits_table WHERE timestamp >= ? AND pair = ?"""
|
||||||
params = (start_date, pair)
|
params = (start_date, pair)
|
||||||
|
|
||||||
with db_cursor() as cursor:
|
with db_cursor() as cursor:
|
||||||
cursor.execute(query, params)
|
cursor.execute(query, params)
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
return result[0] if result[0] else 0
|
return result[0] if result else 0
|
||||||
|
|
||||||
|
|
||||||
def daily_and_monthly_totals() -> tuple[float, float]:
|
def daily_and_monthly_totals() -> tuple[float, float]:
|
||||||
|
|
@ -514,7 +514,7 @@ def get_averages():
|
||||||
with db_cursor() as cursor:
|
with db_cursor() as cursor:
|
||||||
cursor.execute("""SELECT
|
cursor.execute("""SELECT
|
||||||
COALESCE(SUM(CASE WHEN timestamp >= ? THEN amount END), 0) AS sum_30d,
|
COALESCE(SUM(CASE WHEN timestamp >= ? THEN amount END), 0) AS sum_30d,
|
||||||
COALESCE(SUM(CASE WHEN timestamp >= ? THEN amount END), 0) AS sum_7d,
|
COALESCE(SUM(CASE WHEN timestamp >= ? THEN amount END), 0) AS sum_7d
|
||||||
FROM profits_table""",
|
FROM profits_table""",
|
||||||
(time.time()-30*86400, time.time()-7*86400))
|
(time.time()-30*86400, time.time()-7*86400))
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue