From 0e8137afd0545772df9f1219ef4105a7d47fdeb3 Mon Sep 17 00:00:00 2001 From: Alexander Mayes Date: Fri, 4 Sep 2026 11:17:45 -0700 Subject: [PATCH] Scope encounter rankings to the analyzed log's raid phase (partition) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A TBC Fresh user reported comparison DPS looking "omega high, like Sunwell p5 dps". Root cause: ENCOUNTER_RANKINGS_QUERY declares a $partition variable but nothing ever passed it, so WCL fell back to the zone's DEFAULT partition. Fresh zones already have multiple phase partitions (e.g. SSC/TK: P3 exists while P2 is still the default), so a log recorded in the current phase was compared against the previous phase's peak farm-meta parses — the highest numbers that will ever exist for that raid. Fix: piggyback `rankings(fightIDs:)` on the existing player-data queries (zero extra WCL round trips), extract the fight's partition from the report's own ranking data, and pass it to the rankings query. Falls back to WCL's default when the fight has no ranking data (e.g. wipes). Verified against the live WCL API with the repo's exact query strings: partition extraction and scoped rankings both work. Co-Authored-By: Claude Fable 5 --- app/api/analyze/route.ts | 10 ++++++++++ lib/wcl-queries.ts | 2 ++ 2 files changed, 12 insertions(+) diff --git a/app/api/analyze/route.ts b/app/api/analyze/route.ts index 7489cf2..48776ba 100644 --- a/app/api/analyze/route.ts +++ b/app/api/analyze/route.ts @@ -33,6 +33,8 @@ interface PlayerFullDataResponse { playerDetails: Record; }; }; + // WCL report rankings blob — only `partition` is consumed (phase scoping) + rankings?: { data?: Array<{ fightID?: number; partition?: number }> }; damage?: { data: { entries: WCLDamageEntry[] } }; healing?: { data: { entries: WCLDamageEntry[] } }; buffs: { data: { auras: WCLBuffEntry[] } }; @@ -207,6 +209,13 @@ export async function POST(request: NextRequest) { ); } + // Scope rankings to the report's own partition (raid phase). Without it, + // WCL falls back to the zone's default partition, which can compare an + // earlier-phase log against later-phase-geared top parses (inflated DPS). + const fightPartition = report.rankings?.data?.find( + (r) => r.fightID === fightId + )?.partition ?? report.rankings?.data?.[0]?.partition; + let rankingsData: WCLRankingsData; try { const rankingsResponse = await wclQuery( @@ -216,6 +225,7 @@ export async function POST(request: NextRequest) { className: playerClass, specName: playerSpec, metric: playerRole === "healer" ? "hps" : "dps", + partition: typeof fightPartition === "number" ? fightPartition : null, } ); rankingsData = rankingsResponse.worldData.encounter.characterRankings; diff --git a/lib/wcl-queries.ts b/lib/wcl-queries.ts index 205381c..d1ce54d 100644 --- a/lib/wcl-queries.ts +++ b/lib/wcl-queries.ts @@ -86,6 +86,7 @@ export const PLAYER_FULL_DATA_QUERY_HEALING = ` reportData { report(code: $code) { playerDetails(fightIDs: $fightIDs) + rankings(fightIDs: $fightIDs) healing: table( dataType: Healing fightIDs: $fightIDs @@ -225,6 +226,7 @@ export const PLAYER_FULL_DATA_QUERY = ` reportData { report(code: $code) { playerDetails(fightIDs: $fightIDs) + rankings(fightIDs: $fightIDs) damage: table( dataType: DamageDone fightIDs: $fightIDs