From 198f6f843b2a0e08c3da19ceecedcd9fed86a573 Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 23 Jun 2026 19:37:35 -0400 Subject: [PATCH 1/2] Fix Atlas Prometheus queries and pantheon PGCR activity hash resolution. Clamp zero-minute rate windows before building PromQL, and store referenceId when Bungie reports a featured-reprise playlist wrapper in directorActivityHash. Co-authored-by: Cursor --- apps/atlas/metrics_service.go | 4 ++++ lib/services/pgcr_processing/process-pgcr.go | 21 ++++++++++++++++---- lib/web/bungie/types.go | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/apps/atlas/metrics_service.go b/apps/atlas/metrics_service.go index 7ba0e11..fd74683 100644 --- a/apps/atlas/metrics_service.go +++ b/apps/atlas/metrics_service.go @@ -37,6 +37,10 @@ func GetMetricsForScaling(elapsedTime time.Duration) (*AtlasMetrics, error) { // GetMetrics fetches all metrics for the given interval func GetMetrics(intervalMinutes int) (*AtlasMetrics, error) { + if intervalMinutes <= 0 { + intervalMinutes = 1 + } + metrics := &AtlasMetrics{} // Fetch all metrics in parallel would be ideal, but for now we'll do sequentially diff --git a/lib/services/pgcr_processing/process-pgcr.go b/lib/services/pgcr_processing/process-pgcr.go index 27bacec..050042e 100644 --- a/lib/services/pgcr_processing/process-pgcr.go +++ b/lib/services/pgcr_processing/process-pgcr.go @@ -108,9 +108,11 @@ func parsePGCRToInstance(report *bungie.DestinyPostGameCarnageReport) (*dto.Inst completionReason := getStat(report.Entries[0].Values, "completionReason") + activityHash := resolveInstanceActivityHash(report.ActivityDetails) + result := dto.Instance{ InstanceId: report.ActivityDetails.InstanceId, - Hash: report.ActivityDetails.DirectorActivityHash, + Hash: activityHash, // assigned later Fresh: nil, DateStarted: startDate, @@ -249,7 +251,7 @@ func parsePGCRToInstance(report *bungie.DestinyPostGameCarnageReport) (*dto.Inst if err != nil { return nil, false, err } - result.Fresh = normalizeFresh(report.ActivityDetails.DirectorActivityHash, fresh) + result.Fresh = normalizeFresh(activityHash, fresh) if result.Completed && deathless { result.Flawless = result.Fresh @@ -325,6 +327,16 @@ var leviHashes = map[uint32]bool{ 3879860661: true, 3857338478: true, } +// resolveInstanceActivityHash returns the activity hash to store on the instance row. +// Pantheon featured-reprise playlists report the playlist wrapper in directorActivityHash +// and the actual encounter in referenceId. +func resolveInstanceActivityHash(ad bungie.DestinyHistoricalStatsActivity) uint32 { + if ad.ReferenceId != 0 { + return ad.ReferenceId + } + return ad.DirectorActivityHash +} + // normalizeFresh adjusts unreliable Bungie fresh signals for specific activities. func normalizeFresh(activityHash uint32, fresh *bool) *bool { if activityHash != morgethSurpassingHash { @@ -355,11 +367,12 @@ func isFresh(pgcr *bungie.DestinyPostGameCarnageReport, deathless bool) (*bool, // Pre beyond light, using StartingPhaseIndex result = new(bool) startingPhaseIndex := *pgcr.StartingPhaseIndex + activityHash := resolveInstanceActivityHash(pgcr.ActivityDetails) // sotp - if pgcr.ActivityDetails.DirectorActivityHash == 548750096 || pgcr.ActivityDetails.DirectorActivityHash == 2812525063 { + if activityHash == 548750096 || activityHash == 2812525063 { *result = (startingPhaseIndex <= 1) // levi - } else if leviHashes[pgcr.ActivityDetails.DirectorActivityHash] { + } else if leviHashes[activityHash] { *result = (startingPhaseIndex == 0 || startingPhaseIndex == 2) } else { *result = (startingPhaseIndex == 0) diff --git a/lib/web/bungie/types.go b/lib/web/bungie/types.go index 663efb8..e89e606 100644 --- a/lib/web/bungie/types.go +++ b/lib/web/bungie/types.go @@ -47,6 +47,7 @@ type DestinyHistoricalStatsActivity struct { Mode int `json:"mode"` Modes []int `json:"modes"` MembershipType int `json:"membershipType"` + ReferenceId uint32 `json:"referenceId"` DirectorActivityHash uint32 `json:"directorActivityHash"` } From 9fff5437630f60277f1863c5dab4068ac9089ad9 Mon Sep 17 00:00:00 2001 From: owen Date: Tue, 23 Jun 2026 19:42:48 -0400 Subject: [PATCH 2/2] Only prefer referenceId when it differs from directorActivityHash. Normal raid PGCRs report the same hash in both fields; pantheon featured-reprise playlists are the case where they diverge. Co-authored-by: Cursor --- lib/services/pgcr_processing/process-pgcr.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/pgcr_processing/process-pgcr.go b/lib/services/pgcr_processing/process-pgcr.go index 050042e..ccc03d4 100644 --- a/lib/services/pgcr_processing/process-pgcr.go +++ b/lib/services/pgcr_processing/process-pgcr.go @@ -329,9 +329,9 @@ var leviHashes = map[uint32]bool{ // resolveInstanceActivityHash returns the activity hash to store on the instance row. // Pantheon featured-reprise playlists report the playlist wrapper in directorActivityHash -// and the actual encounter in referenceId. +// and the actual encounter in referenceId. For typical raids both fields match. func resolveInstanceActivityHash(ad bungie.DestinyHistoricalStatsActivity) uint32 { - if ad.ReferenceId != 0 { + if ad.ReferenceId != 0 && ad.ReferenceId != ad.DirectorActivityHash { return ad.ReferenceId } return ad.DirectorActivityHash