Spaces:
Sleeping
Sleeping
Create analytics/dashboard.py
Browse files- analytics/dashboard.py +13 -0
analytics/dashboard.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import plotly.express as px
|
| 3 |
+
from db import models
|
| 4 |
+
|
| 5 |
+
def generate_dashboard_figure():
|
| 6 |
+
notes = models.get_all_notes()
|
| 7 |
+
df = pd.DataFrame(notes)
|
| 8 |
+
if df.empty:
|
| 9 |
+
return None
|
| 10 |
+
df['created_at'] = pd.to_datetime(df['created_at'])
|
| 11 |
+
daily = df.groupby(df['created_at'].dt.date).size().reset_index(name='count')
|
| 12 |
+
fig = px.bar(daily, x='created_at', y='count', title='Notes per Day')
|
| 13 |
+
return fig
|