Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -134,7 +134,7 @@ def mongo_distinct(uri: str, db: str, coll: str, field: str) -> List[str]:
|
|
| 134 |
except Exception:
|
| 135 |
return []
|
| 136 |
|
| 137 |
-
def mongo_records(uri: str, db: str, coll: str, student: str | None, source: str | None
|
| 138 |
if not uri:
|
| 139 |
return []
|
| 140 |
q = {}
|
|
@@ -189,17 +189,17 @@ with st.sidebar:
|
|
| 189 |
|
| 190 |
student_choice = st.selectbox("Select student", students)
|
| 191 |
source_choice = st.selectbox("Select source/week", sources)
|
| 192 |
-
start_dt = st.date_input("Start date", value=None)
|
| 193 |
-
end_dt = st.date_input("End date", value=None)
|
| 194 |
grouped = st.toggle("Grouped skills", value=True)
|
| 195 |
overlay_sources = st.toggle("Overlay all sources when '(All)' selected", value=False)
|
| 196 |
chart_title = st.text_input("Chart title", value="")
|
| 197 |
|
| 198 |
-
start_str = start_dt.strftime("%Y-%m-%d") if isinstance(start_dt, date) else None
|
| 199 |
-
end_str = end_dt.strftime("%Y-%m-%d") if isinstance(end_dt, date) else None
|
| 200 |
|
| 201 |
# ------------------- Fetch + merge -------------------
|
| 202 |
-
records = mongo_records(mongo_uri, db_name, coll_name, student_choice, source_choice
|
| 203 |
df_raw = pd.DataFrame(records) if records else pd.DataFrame()
|
| 204 |
|
| 205 |
if not df_raw.empty:
|
|
|
|
| 134 |
except Exception:
|
| 135 |
return []
|
| 136 |
|
| 137 |
+
def mongo_records(uri: str, db: str, coll: str, student: str | None, source: str | None) -> List[dict]:
|
| 138 |
if not uri:
|
| 139 |
return []
|
| 140 |
q = {}
|
|
|
|
| 189 |
|
| 190 |
student_choice = st.selectbox("Select student", students)
|
| 191 |
source_choice = st.selectbox("Select source/week", sources)
|
| 192 |
+
# start_dt = st.date_input("Start date", value=None)
|
| 193 |
+
# end_dt = st.date_input("End date", value=None)
|
| 194 |
grouped = st.toggle("Grouped skills", value=True)
|
| 195 |
overlay_sources = st.toggle("Overlay all sources when '(All)' selected", value=False)
|
| 196 |
chart_title = st.text_input("Chart title", value="")
|
| 197 |
|
| 198 |
+
# start_str = start_dt.strftime("%Y-%m-%d") if isinstance(start_dt, date) else None
|
| 199 |
+
# end_str = end_dt.strftime("%Y-%m-%d") if isinstance(end_dt, date) else None
|
| 200 |
|
| 201 |
# ------------------- Fetch + merge -------------------
|
| 202 |
+
records = mongo_records(mongo_uri, db_name, coll_name, student_choice, source_choice) if mongo_uri else []
|
| 203 |
df_raw = pd.DataFrame(records) if records else pd.DataFrame()
|
| 204 |
|
| 205 |
if not df_raw.empty:
|