diff --git a/TPP.Persistence.MongoDB/Repos/BadgeRepo.cs b/TPP.Persistence.MongoDB/Repos/BadgeRepo.cs index dd12bb14..397c3b07 100644 --- a/TPP.Persistence.MongoDB/Repos/BadgeRepo.cs +++ b/TPP.Persistence.MongoDB/Repos/BadgeRepo.cs @@ -33,6 +33,11 @@ public class BadgeRepo( public readonly IMongoCollection Collection = database.GetCollection(CollectionName); public readonly IMongoCollection CollectionStats = database.GetCollection(CollectionNameStats); + private static readonly Instant WhenGen2WasAddedToPinball = Instant.FromUtc(2018, 3, 28, 12, 00); + /// Instant at which some update was deployed that is expected to majorly disrupt badge rarities, + /// e.g. if a whole new generation was added to pinball. + private static readonly Instant LastRarityUpdate = WhenGen2WasAddedToPinball; + /// Pinball drops enough badges that a somewhat small time-span is already statistically significant. /// Also, if Pinball ever gets tweaked and natural drop chances change, ignoring old badges gradually /// transitions to the new rarities. @@ -248,7 +253,7 @@ public async Task RenewBadgeStats(IImmutableSet? onlyTheseSpecies = { var stopwatch = Stopwatch.StartNew(); Instant now = clock.GetCurrentInstant(); - Instant startTime = now - _rarityCalculationTransition; + Instant startTime = Instant.Min(LastRarityUpdate, now - _rarityCalculationTransition); IAggregateFluent pipeline = Collection.Aggregate(new AggregateOptions { AllowDiskUse = true }); if (onlyTheseSpecies != null)