Skip to content

Commit e081ed6

Browse files
polish the code
1 parent 76a9cb7 commit e081ed6

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/study_smart/app.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
2-
from dash import Dash, html, dcc, Input, Output, State, ALL, ctx
32
import dash
3+
from dash import Dash, html, dcc, Input, Output, State, ALL, ctx
44
import dash_bootstrap_components as dbc
55
import pandas as pd
66
from datetime import date, timedelta
@@ -105,7 +105,7 @@
105105
], fluid=True)
106106

107107

108-
def get_subject_color_map(schedule, exam_list):
108+
def get_subject_color_map(exam_list):
109109
"""Assign one color per exam — all topics of same exam share color."""
110110
exam_names = [e["name"] for e in exam_list]
111111
n = max(len(exam_names), 1)
@@ -121,7 +121,7 @@ def get_subject_color_map(schedule, exam_list):
121121
for e in exam_list:
122122
color = exam_colors[e["name"]]
123123
color_map[e["name"]] = color
124-
for t in e["topics"]: # ← use original topic names, no prefix
124+
for t in e["topics"]:
125125
color_map[t] = color
126126

127127
return color_map, exam_colors
@@ -237,7 +237,7 @@ def build_weekly_view(schedule, spaced, week_offset=0, color_map=None, exam_colo
237237
"minWidth": "0",
238238
"borderRight": "0.5px solid var(--color-border-tertiary)",
239239
"padding": "8px",
240-
"backgroundColor": "var(--color-background-primary)" if not day_rows.empty else "var(--color-background-secondary)"
240+
"backgroundColor": "var(--color-background-primary)"
241241
})
242242
)
243243

@@ -349,13 +349,14 @@ def add_exam(n_clicks, name, exam_date, hours, topics):
349349
table = dbc.Table([
350350
html.Thead(html.Tr([
351351
html.Th("Exam"), html.Th("Date"),
352-
html.Th("Hours"), html.Th("Topics")
352+
html.Th("Hours"), html.Th("Topics"), html.Th("")
353353
])),
354354
html.Tbody(rows)
355355
], bordered=True, hover=True, striped=True, size="sm")
356356

357357
return table
358358

359+
# Callback — delete exam
359360
@app.callback(
360361
Output("exam-table", "children", allow_duplicate=True),
361362
Input({"type": "delete-exam", "index": ALL}, "n_clicks"),
@@ -532,7 +533,7 @@ def import_from_google_calendar(n_clicks, start_date):
532533
end_date = max(date.fromisoformat(e["date"]) for e in exams)
533534
start = date.fromisoformat(start_date)
534535

535-
imported, event_names = import_commitments_from_google_calendar(start, end_date)
536+
imported, _ = import_commitments_from_google_calendar(start, end_date)
536537

537538
for d, h in imported.items():
538539
if d in commitments:
@@ -662,7 +663,7 @@ def generate_schedule(n_clicks, spaced_repetition, default_hours, start_date):
662663
warning_cards.append(dbc.Alert(w, color="warning"))
663664

664665
# build color maps — one color per exam shared across all its topics
665-
color_map, exam_colors = get_subject_color_map(schedule, exam_list)
666+
color_map, exam_colors = get_subject_color_map(exam_list)
666667

667668
# build legend
668669
legend_items = []

src/study_smart/schedule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def generate_tips(schedule, exam_dates, start_date, default_hours=7):
312312
313313
Returns:
314314
list of str: Personalised tips. May include tips on active recall,
315-
deep processing, interleaving, and taking breaks depending on the schedule.
315+
deep processing, and taking breaks depending on the schedule.
316316
317317
Example:
318318
>>> from datetime import date

0 commit comments

Comments
 (0)