feat(server/membership): add ai_points plan policy fields
Introduces ai_points_monthly and ai_point_base_chars on the membership plan policy, exposes them through TenantPlanAccess and MembershipInfo, and seeds Pro with a 1500-point monthly allowance across the local, server, and deploy configs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,38 @@ func (a *TenantPlanAccess) ArticleQuotaCycle() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *TenantPlanAccess) AIPointsMonthlyLimit() int {
|
||||
if a == nil {
|
||||
return 0
|
||||
}
|
||||
return maxInt(a.Policy.AIPointsMonthly, 0)
|
||||
}
|
||||
|
||||
func (a *TenantPlanAccess) AIPointBaseChars() int {
|
||||
if a == nil || a.Policy.AIPointBaseChars <= 0 {
|
||||
return 1000
|
||||
}
|
||||
return a.Policy.AIPointBaseChars
|
||||
}
|
||||
|
||||
func (a *TenantPlanAccess) AIPointsWindow(now time.Time) (time.Time, time.Time, *time.Time) {
|
||||
if a == nil {
|
||||
return time.Time{}, time.Time{}, nil
|
||||
}
|
||||
|
||||
windowStart := a.StartAt.UTC()
|
||||
windowEnd := a.EndAt.UTC()
|
||||
cycleStart, cycleEnd := monthlyCycleBounds(windowStart, now.UTC())
|
||||
if cycleStart.Before(windowStart) {
|
||||
cycleStart = windowStart
|
||||
}
|
||||
if !windowEnd.IsZero() && cycleEnd.After(windowEnd) {
|
||||
cycleEnd = windowEnd
|
||||
}
|
||||
resetAt := cycleEnd
|
||||
return cycleStart, cycleEnd, &resetAt
|
||||
}
|
||||
|
||||
func (a *TenantPlanAccess) ArticleQuotaWindow(now time.Time) (time.Time, time.Time, *time.Time) {
|
||||
if a == nil {
|
||||
return time.Time{}, time.Time{}, nil
|
||||
|
||||
Reference in New Issue
Block a user