enlarge journal calendar cells and pair day/title on one line
- calendar-cell-journal: bump min-height 44px -> 76px, scale up date/dot/title font sizes - journal calendar titles were centered; left-align them - rework JournalCalendarDay: replace separate category_colors/titles lists (mismatched lengths, no way to pair a dot with its title) with a single entries list of (color, title) pairs so the dot and its title render on the same non-wrapping row per entry Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ from app.models.journal import (
|
||||
from app.schemas.journal import (
|
||||
JournalAttachmentOut,
|
||||
JournalCalendarDay,
|
||||
JournalCalendarEntry,
|
||||
JournalCategoryCreate,
|
||||
JournalDayDetailItem,
|
||||
JournalEntryCreate,
|
||||
@@ -363,25 +364,33 @@ def get_monthly_journal_summary(
|
||||
last_day = date(year, month, days_in_month)
|
||||
|
||||
stmt = (
|
||||
select(JournalEntry.entry_date, JournalCategory.color)
|
||||
select(JournalEntry.entry_date, JournalCategory.color, JournalEntry.title, JournalEntry.content)
|
||||
.join(JournalCategory, JournalEntry.category_id == JournalCategory.id)
|
||||
.where(JournalEntry.user_id == user_id, JournalEntry.entry_date.between(first_day, last_day))
|
||||
.order_by(JournalEntry.entry_date, JournalEntry.created_at)
|
||||
)
|
||||
if category_id is not None:
|
||||
stmt = stmt.where(JournalEntry.category_id == category_id)
|
||||
rows = db.execute(stmt).all()
|
||||
|
||||
counts: dict[date, int] = {}
|
||||
colors_by_date: dict[date, list[str]] = {}
|
||||
for entry_date, color in rows:
|
||||
entries_by_date: dict[date, list[JournalCalendarEntry]] = {}
|
||||
for entry_date, color, title, content in rows:
|
||||
counts[entry_date] = counts.get(entry_date, 0) + 1
|
||||
colors = colors_by_date.setdefault(entry_date, [])
|
||||
color = color or "var(--color-accent)"
|
||||
if color not in colors:
|
||||
colors.append(color)
|
||||
entries = entries_by_date.setdefault(entry_date, [])
|
||||
entries.append(
|
||||
JournalCalendarEntry(
|
||||
color=color or "var(--color-accent)",
|
||||
title=title or (content[:12] + ("…" if len(content) > 12 else "")),
|
||||
)
|
||||
)
|
||||
|
||||
return {
|
||||
d: JournalCalendarDay(entry_date=d, total_count=counts[d], category_colors=colors_by_date[d])
|
||||
d: JournalCalendarDay(
|
||||
entry_date=d,
|
||||
total_count=counts[d],
|
||||
entries=entries_by_date[d],
|
||||
)
|
||||
for d in counts
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user