refactor(calendar): expose AllTime via GameCalendarPeriods, not the concrete service
Move the "all-time" constant out of GameCalendarService (concrete) into a new static class GameCalendarPeriods. Consumers using IGameCalendarService no longer have to reach through the concrete class to name the lifetime bucket. Migrates 5 callsites (mission progress/assembler, admin, item purchase, tests). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -629,7 +629,7 @@ public class AdminController : SVSimController
|
||||
private static (string EventKey, string Period)? ResolveAchievementCounter(AchievementCatalogEntry catalog)
|
||||
{
|
||||
if (string.IsNullOrEmpty(catalog.EventType)) return null;
|
||||
return (catalog.EventType!, GameCalendarService.AllTime);
|
||||
return (catalog.EventType!, GameCalendarPeriods.AllTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ItemPurchaseController : SVSimController
|
||||
return BadRequest(new { error = "unknown_purchase" });
|
||||
|
||||
var now = _time.GetUtcNow();
|
||||
var period = entry.IsMonthlyReset ? _calendar.MonthKey(now) : GameCalendarService.AllTime;
|
||||
var period = entry.IsMonthlyReset ? _calendar.MonthKey(now) : GameCalendarPeriods.AllTime;
|
||||
var key = CounterKey(entry.Id);
|
||||
|
||||
var counter = await _db.ViewerEventCounters
|
||||
@@ -160,11 +160,11 @@ public class ItemPurchaseController : SVSimController
|
||||
_ => "debit_type_not_supported",
|
||||
};
|
||||
|
||||
private static string CounterKey(int purchaseId) => $"item_purchase:{purchaseId}";
|
||||
private static string CounterKey(int purchaseId) => MissionEventKeys.ItemPurchase(purchaseId);
|
||||
|
||||
private static int CounterCount(List<ViewerEventCounter> counters, ItemPurchaseCatalogEntry entry, string monthKey)
|
||||
{
|
||||
var period = entry.IsMonthlyReset ? monthKey : GameCalendarService.AllTime;
|
||||
var period = entry.IsMonthlyReset ? monthKey : GameCalendarPeriods.AllTime;
|
||||
return counters.FirstOrDefault(c => c.EventKey == CounterKey(entry.Id) && c.Period == period)?.Count ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user