MCPcopy Create free account
hub / github.com/0010aor/FlashNotes / _get_recent_sessions

Function _get_recent_sessions

backend/src/stats/services.py:42–67  ·  view source on GitHub ↗

Get recent practice sessions using an optimized query.

(
    session: Session, collection_id: uuid.UUID, limit: int = 10
)

Source from the content-addressed store, hash-verified

40
41
42def _get_recent_sessions(
43 session: Session, collection_id: uuid.UUID, limit: int = 10
44) -> list[PracticeSessionStats]:
45 """Get recent practice sessions using an optimized query."""
46 statement = (
47 select(PracticeSession)
48 .where(
49 PracticeSession.collection_id == collection_id,
50 PracticeSession.is_completed,
51 )
52 .order_by(PracticeSession.created_at.asc())
53 .limit(limit)
54 )
55
56 sessions = session.exec(statement).all()
57 return [
58 PracticeSessionStats(
59 id=s.id,
60 created_at=s.created_at,
61 cards_practiced=s.cards_practiced,
62 correct_answers=s.correct_answers,
63 total_cards=s.total_cards,
64 is_completed=s.is_completed,
65 )
66 for s in sessions
67 ]
68
69
70def _get_difficult_cards(

Callers 2

test_get_recent_sessionsFunction · 0.90
get_collection_statsFunction · 0.85

Calls 1

Tested by 1

test_get_recent_sessionsFunction · 0.72