forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfocus_session.py
More file actions
48 lines (35 loc) · 2.24 KB
/
Copy pathfocus_session.py
File metadata and controls
48 lines (35 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Focus sessions — focus/distraction tracking and statistics.
Response wire shapes for /v1/focus-sessions* and /v1/focus-stats. Source of
truth for the focus-session response schema; routers/database construct dicts
matching these fields.
Collection: users/{uid}/focus_sessions.
"""
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
class FocusSession(BaseModel):
"""A single focus/distraction session record."""
id: str = Field(description='Unique session identifier.')
status: str = Field(description='Session status, "focused" or "distracted".')
app_or_site: str = Field(description='App or website the session refers to.')
description: str = Field(description='Free-text description of the session.')
message: Optional[str] = Field(default=None, description='Optional user message attached to the session.')
created_at: datetime = Field(description='When the session was recorded (UTC).')
duration_seconds: Optional[int] = Field(default=None, ge=0, description='Session duration in seconds, if known.')
class FocusDistraction(BaseModel):
"""One entry in the top-distractions breakdown of /v1/focus-stats."""
app_or_site: str = Field(description='App or website that caused the distraction.')
total_seconds: int = Field(ge=0, description='Total distracted seconds attributed to this app/site.')
count: int = Field(ge=0, description='Number of distracted sessions for this app/site.')
class FocusStats(BaseModel):
"""Aggregated focus statistics returned by /v1/focus-stats."""
date: str = Field(description='The date (YYYY-MM-DD) the stats cover.')
focused_minutes: int = Field(ge=0, description='Total focused time, in whole minutes.')
distracted_minutes: int = Field(ge=0, description='Total distracted time, in whole minutes.')
session_count: int = Field(ge=0, description='Total number of sessions considered.')
focused_count: int = Field(ge=0, description='Number of focused sessions.')
distracted_count: int = Field(ge=0, description='Number of distracted sessions.')
top_distractions: list[FocusDistraction] = Field(
default_factory=list,
description='Up to five most distracting apps/sites by total distracted seconds.',
)