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

Function get_ai_usage_quota_for_user

backend/src/users/services.py:51–68  ·  view source on GitHub ↗
(user: User)

Source from the content-addressed store, hash-verified

49
50
51def get_ai_usage_quota_for_user(user: User) -> AIUsageQuota:
52 quota = user.ai_usage_quota
53 if not quota:
54 return AIUsageQuota(
55 usage_count=0,
56 max_usage_allowed=settings.AI_MAX_USAGE_QUOTA,
57 reset_date=(
58 datetime.now(timezone.utc)
59 + timedelta(days=settings.AI_QUOTA_TIME_RANGE_DAYS)
60 ),
61 )
62 return AIUsageQuota(
63 usage_count=quota.usage_count,
64 max_usage_allowed=settings.AI_MAX_USAGE_QUOTA,
65 reset_date=(
66 quota.last_reset_time + timedelta(days=settings.AI_QUOTA_TIME_RANGE_DAYS)
67 ),
68 )
69
70
71def check_and_increment_ai_usage_quota(session: Session, user: User) -> bool:

Calls 1

AIUsageQuotaClass · 0.90