Skip to content

Commit 9f7c5ce

Browse files
fix: pandas formatting
1 parent d59d26e commit 9f7c5ce

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def get_events(
421421
if not os.path.exists(json_fn) or os.stat(json_fn).st_size == 0:
422422
return {"message": "No events found", "events": []}
423423

424-
return pd.read_json(json_fn)
424+
return pd.read_json(json_fn).to_dict('records')
425425

426426

427427
@api_router.get("/check-schedule")

app/slackbot.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ def fmt_json(filename):
7676
# create dataframe
7777
df = pd.DataFrame(data)
7878

79+
# handle empty dataframe case
80+
if df.empty:
81+
return []
82+
7983
# add column: 'message' with date, name, title, eventUrl
8084
df['message'] = df.apply(lambda x: f'• {x["date"]} *{x["name"]}* <{x["eventUrl"]}|{x["title"]}> ', axis=1)
8185

0 commit comments

Comments
 (0)