forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_usage.py
More file actions
51 lines (35 loc) · 1.16 KB
/
Copy pathuser_usage.py
File metadata and controls
51 lines (35 loc) · 1.16 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
49
50
51
from datetime import datetime, timezone
from enum import Enum
from typing import List, Optional
from pydantic import BaseModel, Field
def _utc_now() -> datetime:
return datetime.now(timezone.utc).replace(tzinfo=None)
class UsageStats(BaseModel):
"""Represents a set of usage metrics for a period."""
transcription_seconds: int = 0
words_transcribed: int = 0
insights_gained: int = 0
memories_created: int = 0
speech_seconds: int = 0
class UsagePeriod(str, Enum):
TODAY = "today"
MONTHLY = "monthly"
YEARLY = "yearly"
ALL_TIME = "all_time"
class UsageHistoryPoint(UsageStats):
date: str
class UserUsageResponse(BaseModel):
"""The response model for the user usage API endpoint."""
today: Optional[UsageStats] = None
monthly: Optional[UsageStats] = None
yearly: Optional[UsageStats] = None
all_time: Optional[UsageStats] = None
history: Optional[List[UsageHistoryPoint]] = None
class HourlyUsage(UsageStats):
"""Represents the hourly usage data stored in the database."""
uid: str
year: int
month: int
day: int
hour: int
last_updated: datetime = Field(default_factory=_utc_now)