one month
Browse files
app.py
CHANGED
@@ -41,22 +41,29 @@ def get_logger():
|
|
41 |
logger = get_logger()
|
42 |
|
43 |
def get_last_one_month_data():
|
|
|
|
|
|
|
|
|
44 |
con = duckdb.connect(':memory:')
|
|
|
45 |
|
46 |
# Query to fetch data from all_trades_profitability.parquet
|
47 |
query2 = f"""
|
48 |
SELECT *
|
49 |
FROM read_parquet('./data/all_trades_profitability.parquet')
|
|
|
50 |
"""
|
51 |
df2 = con.execute(query2).fetchdf()
|
52 |
-
|
53 |
-
|
54 |
query1 = f"""
|
55 |
SELECT *
|
56 |
FROM read_parquet('./data/tools.parquet')
|
57 |
WHERE request_time >= '{one_months_ago}'
|
58 |
"""
|
59 |
df1 = con.execute(query1).fetchdf()
|
|
|
60 |
|
61 |
con.close()
|
62 |
|
@@ -64,6 +71,9 @@ def get_last_one_month_data():
|
|
64 |
|
65 |
|
66 |
def prepare_data():
|
|
|
|
|
|
|
67 |
tools_df, trades_df = get_last_one_month_data()
|
68 |
|
69 |
tools_df['request_time'] = pd.to_datetime(tools_df['request_time'])
|
|
|
41 |
logger = get_logger()
|
42 |
|
43 |
def get_last_one_month_data():
|
44 |
+
"""
|
45 |
+
Get the last one month data from the tools.parquet file
|
46 |
+
"""
|
47 |
+
logger.info("Getting last one month data")
|
48 |
con = duckdb.connect(':memory:')
|
49 |
+
one_months_ago = (datetime.now() - timedelta(days=60)).strftime('%Y-%m-%d')
|
50 |
|
51 |
# Query to fetch data from all_trades_profitability.parquet
|
52 |
query2 = f"""
|
53 |
SELECT *
|
54 |
FROM read_parquet('./data/all_trades_profitability.parquet')
|
55 |
+
WHERE request_time >= '{one_months_ago}'
|
56 |
"""
|
57 |
df2 = con.execute(query2).fetchdf()
|
58 |
+
logger.info("Got last one month data from all_trades_profitability.parquet")
|
59 |
+
|
60 |
query1 = f"""
|
61 |
SELECT *
|
62 |
FROM read_parquet('./data/tools.parquet')
|
63 |
WHERE request_time >= '{one_months_ago}'
|
64 |
"""
|
65 |
df1 = con.execute(query1).fetchdf()
|
66 |
+
logger.info("Got last one month data from tools.parquet")
|
67 |
|
68 |
con.close()
|
69 |
|
|
|
71 |
|
72 |
|
73 |
def prepare_data():
|
74 |
+
"""
|
75 |
+
Prepare the data for the dashboard
|
76 |
+
"""
|
77 |
tools_df, trades_df = get_last_one_month_data()
|
78 |
|
79 |
tools_df['request_time'] = pd.to_datetime(tools_df['request_time'])
|