feat(plans): report-history + AI-3D limits read from the catalog (S3 finish)
CI/CD / CI · API (dotnet build + test) (push) Successful in 43s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 31s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m4s
CI/CD / CI · Admin Web (tsc) (push) Has been cancelled
CI/CD / CI · Website (tsc) (push) Has been cancelled
CI/CD / CI · Koja (tsc) (push) Has been cancelled
CI/CD / Deploy · all services (push) Has been cancelled
CI/CD / CI · API (dotnet build + test) (push) Successful in 43s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 31s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m4s
CI/CD / CI · Admin Web (tsc) (push) Has been cancelled
CI/CD / CI · Website (tsc) (push) Has been cancelled
CI/CD / CI · Koja (tsc) (push) Has been cancelled
CI/CD / Deploy · all services (push) Has been cancelled
The last two limits that still read hardcoded PlanLimits now come from the admin-editable catalog, so editing them in the admin panel takes effect: - ReportPlanGate is now limit-driven (takes int maxDays, not a tier); ReportsController resolves MaxReportHistoryDays from catalog.GetLimitsAsync. LimitMessage is generic (reflects the actual days). EnsureReportDateAllowed is now async. - MenuAi3dGenerationService.ResolveLimitAsync reads MaxMenuAi3dPerMonth from the catalog. Every plan limit + feature gate is now DB-driven and admin-editable. 86 tests pass.
This commit is contained in:
@@ -141,7 +141,7 @@ public class MenuAi3dGenerationService : IMenuAi3dGenerationService
|
||||
{
|
||||
if (!await _catalog.IsFeatureEnabledForCafeAsync(cafeId, planTier, FeatureMenu3dAi, cancellationToken))
|
||||
return 0;
|
||||
return PlanLimits.MaxMenuAi3dPerMonth(planTier);
|
||||
return (await _catalog.GetLimitsAsync(planTier, cancellationToken)).MaxMenuAi3dPerMonth;
|
||||
}
|
||||
|
||||
private static string UsageKey(string cafeId) =>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Meezi.Core.Constants;
|
||||
using Meezi.Core.Enums;
|
||||
|
||||
namespace Meezi.API.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Report-history window checks. Takes the (admin-editable) max-history days
|
||||
/// directly so the limit comes from the plan catalog, not a hardcoded tier table.
|
||||
/// </summary>
|
||||
public static class ReportPlanGate
|
||||
{
|
||||
public static bool IsDateInRange(PlanTier tier, DateOnly date, DateOnly todayIran)
|
||||
public static bool IsDateInRange(int maxDays, DateOnly date, DateOnly todayIran)
|
||||
{
|
||||
var maxDays = PlanLimits.MaxReportHistoryDays(tier);
|
||||
if (maxDays == int.MaxValue)
|
||||
return date <= todayIran;
|
||||
|
||||
@@ -16,16 +16,15 @@ public static class ReportPlanGate
|
||||
}
|
||||
|
||||
public static (DateOnly From, DateOnly To)? ClampRange(
|
||||
PlanTier tier,
|
||||
int maxDays,
|
||||
DateOnly from,
|
||||
DateOnly to,
|
||||
DateOnly todayIran)
|
||||
{
|
||||
if (from > to) return null;
|
||||
if (!IsDateInRange(tier, to, todayIran) || !IsDateInRange(tier, from, todayIran))
|
||||
if (!IsDateInRange(maxDays, to, todayIran) || !IsDateInRange(maxDays, from, todayIran))
|
||||
return null;
|
||||
|
||||
var maxDays = PlanLimits.MaxReportHistoryDays(tier);
|
||||
if (maxDays == int.MaxValue)
|
||||
return (from, to);
|
||||
|
||||
@@ -36,16 +35,8 @@ public static class ReportPlanGate
|
||||
return (clampedFrom, clampedTo);
|
||||
}
|
||||
|
||||
public static string LimitMessage(PlanTier tier)
|
||||
{
|
||||
var days = PlanLimits.MaxReportHistoryDays(tier);
|
||||
return tier switch
|
||||
{
|
||||
PlanTier.Free =>
|
||||
"Daily reports on the Free plan are limited to today and the previous 7 days. Upgrade to Pro for 90 days of history.",
|
||||
PlanTier.Pro =>
|
||||
"Daily reports on the Pro plan are limited to the last 90 days. Upgrade to Business for unlimited history.",
|
||||
_ => "Report date is outside your plan range."
|
||||
};
|
||||
}
|
||||
public static string LimitMessage(int maxDays) =>
|
||||
maxDays == int.MaxValue
|
||||
? "Report date is outside the allowed range."
|
||||
: $"Daily reports on your plan are limited to the last {maxDays} days. Upgrade for more history.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user