refactor(admin,item-purchase): migrate to IGameCalendarService

Swaps 6 JstPeriod.* callsites across AdminController (mission counter
resolution for the /admin catalog) and ItemPurchaseController (monthly
reset bucket key + all-time period).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-07-04 11:52:53 -04:00
parent 2b0cd516f0
commit 448153d592
2 changed files with 13 additions and 9 deletions

View File

@@ -24,13 +24,15 @@ public class AdminController : SVSimController
private readonly IViewerRepository _viewerRepository;
private readonly SVSimDbContext _dbContext;
private readonly ILogger<AdminController> _logger;
private readonly IGameCalendarService _calendar;
public AdminController(IViewerRepository viewerRepository, SVSimDbContext dbContext,
ILogger<AdminController> logger)
ILogger<AdminController> logger, IGameCalendarService calendar)
{
_viewerRepository = viewerRepository;
_dbContext = dbContext;
_logger = logger;
_calendar = calendar;
}
/// <summary>
@@ -610,13 +612,13 @@ public class AdminController : SVSimController
}
// TODO: unify with MissionAssembler.cs — same logic duplicated here.
private static (string EventKey, string Period)? ResolveMissionCounter(MissionCatalogEntry catalog, DateTimeOffset nowUtc)
private (string EventKey, string Period)? ResolveMissionCounter(MissionCatalogEntry catalog, DateTimeOffset nowUtc)
{
if (string.IsNullOrEmpty(catalog.EventType)) return null;
var period = catalog.LotType switch
{
6 => JstPeriod.DayKey(nowUtc),
2 => JstPeriod.WeekKey(nowUtc),
6 => _calendar.DayKey(nowUtc),
2 => _calendar.WeekKey(nowUtc),
_ => null
};
if (period is null) return null;
@@ -627,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!, JstPeriod.AllTime);
return (catalog.EventType!, GameCalendarService.AllTime);
}
/// <summary>