Skip to content

Commit

Permalink
Merge pull request #110 from Alex-At-Home/indiv_luck
Browse files Browse the repository at this point in the history
[#100][#59] Individual luck
  • Loading branch information
Alex-At-Home authored Jul 24, 2020
2 parents c533433 + 4877281 commit 355122c
Show file tree
Hide file tree
Showing 30 changed files with 10,443 additions and 344 deletions.
12 changes: 9 additions & 3 deletions src/components/GameFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const GameFilter: React.FunctionComponent<Props> = ({onStats, startingState, onC
//(common visualization fields across all tables)
luck: startLuck,
//(these fields are for the team view)
onOffLuck: startOnOffLuck, showOnOffLuckDiags: startShowOnOffLuckDiags,
onOffLuck: startOnOffLuck,
showOnOffLuckDiags: startShowOnOffLuckDiags,
showPlayerOnOffLuckDiags: startShowPlayerOnOffLuckDiags,
//(these fields are for the individual view)
filter: startFilter, sortBy: startSortBy,
showBase: startShowBase, showExpanded: startShowExpanded,
Expand Down Expand Up @@ -81,7 +83,9 @@ const GameFilter: React.FunctionComponent<Props> = ({onStats, startingState, onC
// Common luck stats across all tables:
luck: startLuck,
// Team luck stats:
onOffLuck: startOnOffLuck, showOnOffLuckDiags: startShowOnOffLuckDiags,
onOffLuck: startOnOffLuck,
showOnOffLuckDiags: startShowOnOffLuckDiags,
showPlayerOnOffLuckDiags: startShowPlayerOnOffLuckDiags,
// Individual stats:
autoOffQuery: autoOffQuery,
filter: startFilter, sortBy: startSortBy,
Expand All @@ -102,6 +106,7 @@ const GameFilter: React.FunctionComponent<Props> = ({onStats, startingState, onC
minRank: ParamDefaults.defaultMinRank, maxRank: ParamDefaults.defaultMaxRank,
baseQuery: "", onQuery: "", offQuery: ""
};
//TODO: also if the main query minus/on-off matches can't we just re-use that?!

return [ primaryRequest, [{
context: ParamPrefixes.roster as ParamPrefixesType, paramsObj: primaryRequest
Expand All @@ -119,7 +124,8 @@ const GameFilter: React.FunctionComponent<Props> = ({onStats, startingState, onC
const teamJson = jsonResps?.[0]?.responses?.[0] || {};
const rosterCompareJson = jsonResps?.[1]?.responses?.[0] || {};
const rosterStatsJson = jsonResps?.[2]?.responses?.[0] || {};
const globalRosterStatsJson = jsonResps?.[3]?.responses?.[0] || rosterStatsJson;
const globalRosterStatsJson = jsonResps?.[3]?.responses?.[0] || _.cloneDeep(rosterStatsJson);
//(need to clone it so that changes to baseline don't overwrite global)

onStats({
on: teamJson?.aggregations?.tri_filter?.buckets?.on || {},
Expand Down
45 changes: 33 additions & 12 deletions src/components/LineupStatsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ export type LineupStatsModel = {
error_code?: string
}
type Props = {
lineupStats: LineupStatsModel,
teamStats: TeamStatsModel,
rosterStats: RosterStatsModel,
startingState: LineupFilterParams;
onChangeState: (newParams: LineupFilterParams) => void;
startingState: LineupFilterParams,
dataEvent: {
lineupStats: LineupStatsModel,
teamStats: TeamStatsModel,
rosterStats: RosterStatsModel,
},
onChangeState: (newParams: LineupFilterParams) => void
}

const LineupStatsTable: React.FunctionComponent<Props> = ({lineupStats, teamStats, rosterStats, startingState, onChangeState}) => {
const LineupStatsTable: React.FunctionComponent<Props> = ({startingState, dataEvent, onChangeState}) => {
const { lineupStats, teamStats, rosterStats } = dataEvent;

const server = (typeof window === `undefined`) ? //(ensures SSR code still compiles)
"server" : window.location.hostname
Expand Down Expand Up @@ -145,12 +148,29 @@ const LineupStatsTable: React.FunctionComponent<Props> = ({lineupStats, teamStat
const baselinePlayerInfo = _.fromPairs(
(rosterStats.baseline || []).map((mutableP: any) => {
// Add ORtg to lineup stats:
const [ oRtg, adjORtg, oRtgDiag ] = RatingUtils.buildORtg(mutableP, avgEfficiency, false);
const [ dRtg, adjDRtg, dRtgDiag ] = RatingUtils.buildDRtg(mutableP, avgEfficiency, false);
mutableP.off_rtg = oRtg;
mutableP.off_adj_rtg = adjORtg;
mutableP.def_rtg = dRtg;
mutableP.def_adj_rtg = adjDRtg;
const playerAdjustForLuck = false; //TODO: longer term I think we will want to do this
const [ oRtg, adjORtg, rawORtg, rawAdjORtg, oRtgDiag ] = RatingUtils.buildORtg(
mutableP, avgEfficiency, false, playerAdjustForLuck
);
const [ dRtg, adjDRtg, rawDRtg, rawAdjDRtg, dRtgDiag ] = RatingUtils.buildDRtg(
mutableP, avgEfficiency, false, playerAdjustForLuck
);
mutableP.off_rtg = {
value: oRtg?.value, old_value: rawORtg?.value,
override: playerAdjustForLuck ? "Luck adjusted" : undefined
};
mutableP.off_adj_rtg = {
value: adjORtg?.value, old_value: rawAdjORtg?.value,
override: playerAdjustForLuck ? "Luck adjusted" : undefined
};
mutableP.def_rtg = {
value: dRtg?.value, old_value: rawDRtg?.value,
override: playerAdjustForLuck ? "Luck adjusted" : undefined
};
mutableP.def_adj_rtg = {
value: adjDRtg?.value, old_value: rawAdjDRtg?.value,
override: playerAdjustForLuck ? "Luck adjusted" : undefined
};

return [ mutableP.key, mutableP ];
})
Expand Down Expand Up @@ -430,6 +450,7 @@ const LineupStatsTable: React.FunctionComponent<Props> = ({lineupStats, teamStat
truthVal={false}
onSelect={() => setShowLuckConfig(true)}
/>
<Dropdown.Divider />
<GenericTogglingMenuItem
text="Show Luck Adjustment diagnostics"
truthVal={showLuckAdjDiags}
Expand Down
Loading

1 comment on commit 355122c

@vercel
Copy link

@vercel vercel bot commented on 355122c Jul 24, 2020

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.