Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor stats to use turn_scorings #129

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

avimoondra
Copy link
Owner

@avimoondra avimoondra commented Feb 1, 2021

Refactor stats page + score in turn context panel to use turns --> scorings vs. turns.completed_card_ids

@avimoondra avimoondra force-pushed the avimoondra/refactor-stats branch 2 times, most recently from 33a447b to 7226f3e Compare February 1, 2021 05:43
teamPlayerIds.includes(turn.player_id)
)
return flatMap(teamTurns, (turn) => turn.completed_card_ids).length
Copy link
Owner Author

Choose a reason for hiding this comment

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

Remove dependency on completed_card_ids for this calculation since each scoring record per turn has a "score" (0, -1, 1, etc.) that will be used to determine score (no longer just number of cards)

We'll keep completed_card_ids around as a convenience for other use cases like "which cards are left in the bowl?" -- but we could also use the scoring records that are not status "skipped"

Comment on lines +31 to +41
const numTurns = currentGame.turns.length
const [fetchStats, { data }] = useGameStatsLazyQuery({
fetchPolicy: "no-cache",
})

React.useEffect(() => {
fetchStats()
}, [numTurns, fetchStats])
Copy link
Owner Author

Choose a reason for hiding this comment

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

the best I could come up with to keep this score up to date (only runs, when the number of turns change -- i.e. when a new turn is created as part of someone's turn finishing)

no-cache hits server directly, and doesn't cache the result - https://medium.com/@galen.corey/understanding-apollo-fetch-policies-705b5ad71980

highScorePlayers,
teamScores,
winningTeam,
tie,
Copy link
Owner Author

Choose a reason for hiding this comment

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

we can add more keys here like...

teamScoresByRound
playerScoresByRound
mostDifficultCard
mostDifficultCardByRound

mostSkips
leastSkips

--- other ideas

who submitted which word

@avimoondra
Copy link
Owner Author

@avimoondra
Copy link
Owner Author

@render
Copy link

render bot commented Feb 22, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant