Skip to content

Commit

Permalink
fix: percentiles of compositions in detail views
Browse files Browse the repository at this point in the history
  • Loading branch information
sebald committed Oct 1, 2023
1 parent 8e8cb2d commit 263b183
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/stats/details/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { SquadEntitiyWithXWS } from '@/lib/db/types';
import type { Ships } from '@/lib/get-value';
import type {
GameRecord,
SquadData,
XWSFaction,
XWSSquad,
XWSUpgrades,
Expand Down Expand Up @@ -282,7 +281,6 @@ export const compositionDetails = ({
squads,
count,
}: CompositionDetailsProps) => {
const total = squads.length;
const stats: SquadCompositionData = {
id: composition,
// Get first squad to derive faction
Expand All @@ -300,25 +298,20 @@ export const compositionDetails = ({
return;
}

const pct = percentile(
current.rank.elimination ?? current.rank.swiss,
total
);

// Overall stats
stats.count += 1;
stats.record.wins += current.record.wins;
stats.record.ties += current.record.ties;
stats.record.losses += current.record.losses;
stats.percentiles.push(pct);
stats.percentiles.push(current.percentile);

stats.squads.push({
id: createPilotsId(current.xws),
player: current.player,
xws: current.xws,
date: current.date,
record: current.record,
percentile: pct,
percentile: current.percentile,
});

// Stats based on pilot
Expand All @@ -336,7 +329,7 @@ export const compositionDetails = ({
pilot.record.wins += current.record.wins;
pilot.record.ties += current.record.ties;
pilot.record.losses += current.record.losses;
pilot.percentiles.push(pct);
pilot.percentiles.push(current.percentile);

stats.pilot[pid] = pilot;
});
Expand Down

1 comment on commit 263b183

@vercel
Copy link

@vercel vercel bot commented on 263b183 Oct 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.