Skip to content

Stats: Display on Profile the user's top, average and median score #77

Description

@vimark1

Render user's time top, average and median score

There should be dropdown to allow the user to see top, average and median from a time range:

  • Last 24 hours
  • Last month
  • All time

User sessions are stored in

typist/src/Main/index.js

Lines 187 to 218 in 1f8c297

async saveScore() {
try {
const { user } = this.props;
if (!user.uid) return this.setState({ authError: true });
this.setState({ authError: false, error: '' });
const { score } = this.state;
// a string in the format 2018-10-26
const sessionId = (new Date()).toISOString().slice(0,10);
// store record in Firebase
await firebase
.database()
.ref('user-score')
.child(user.uid)
.child(sessionId)
.push({
score,
timestamp: firebase.database.ServerValue.TIMESTAMP
});
this.updateScoreboard(user, score)
} catch (err) {
console.error(err);
this.setState({
error:
'Something went wrong while saving score, please contact support!'
});
}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions