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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user