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 >= ?"
|
||||
params = (start_date,)
|
||||
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)
|
||||
|
||||
with db_cursor() as cursor:
|
||||
cursor.execute(query, params)
|
||||
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]:
|
||||
|
|
@ -514,7 +514,7 @@ def get_averages():
|
|||
with db_cursor() as cursor:
|
||||
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_7d,
|
||||
COALESCE(SUM(CASE WHEN timestamp >= ? THEN amount END), 0) AS sum_7d
|
||||
FROM profits_table""",
|
||||
(time.time()-30*86400, time.time()-7*86400))
|
||||
row = cursor.fetchone()
|
||||
|
|
|
|||
Loading…
Reference in New Issue