Skip to content

Commit

Permalink
Update statistics to round average words
Browse files Browse the repository at this point in the history
  • Loading branch information
Dantaro committed Jun 16, 2020
1 parent b844485 commit e2467dd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "one-nice-thing",
"version": "1.1.0",
"version": "1.1.1",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.28",
Expand Down
2 changes: 1 addition & 1 deletion src/appshell/AppShell.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default ({ children }) => {
</ListItem>
</Link>
<ListItem>
<Typography variant="subtitle2">v1.1.0</Typography>
<Typography variant="subtitle2">v1.1.1</Typography>
</ListItem>
</List>
</div>
Expand Down
14 changes: 8 additions & 6 deletions src/page/statistics/Statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Paper from '@material-ui/core/Paper'
import { useSelector } from 'react-redux'
import {
findMostConsecutiveDays,
findAverageWordCount,
findAverageWordCountRounded,
findLongestNote,
} from 'util/notelist'
import { makeStyles } from '@material-ui/core/styles'
Expand All @@ -25,7 +25,7 @@ export const Statistics = () => {
const classes = useStyles()
const noteList = useSelector((state) => state.noteList)
const bestStreak = findMostConsecutiveDays(noteList)
const averageWordCount = findAverageWordCount(noteList)
const averageWordCount = findAverageWordCountRounded(noteList)
const longestNote = findLongestNote(noteList)
return (
<div>
Expand All @@ -48,15 +48,17 @@ export const Statistics = () => {
{`${bestStreak} ${bestStreak === 1 ? 'day' : 'days'}`}
</Typography>
<Typography variant="body1" gutterBottom>
Average word count:{' '}
{`${averageWordCount} ${
averageWordCount === 1 ? 'word' : 'words'
}`}
Average word count: {' '}
{`${averageWordCount} ${averageWordCount === 1 ? 'word' : 'words'}`}
</Typography>
<Typography variant="body1" gutterBottom>
Longest Note:{' '}
{`${longestNote} ${longestNote === 1 ? 'word' : 'words'}`}
</Typography>
<br/>
<Typography variant="body2">
Have an idea for other statistics? <a href="mailto:[email protected]">Shoot over an email</a> with your suggestions!
</Typography>
</Paper>
</div>
)
Expand Down
3 changes: 3 additions & 0 deletions src/util/notelist/NoteListUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export const findAverageWordCount = (noteList) => {
)
}

export const findAverageWordCountRounded = (noteList) =>
Math.round(findAverageWordCount(noteList))

export const findLongestNote = (noteList) => {
if (!noteList || noteList.length === 0) {
return 0
Expand Down
2 changes: 2 additions & 0 deletions src/util/notelist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import {
findMostConsecutiveDays,
findCurrentStreak,
findAverageWordCount,
findAverageWordCountRounded,
findLongestNote,
} from './NoteListUtil'

export {
findMostConsecutiveDays,
findCurrentStreak,
findAverageWordCount,
findAverageWordCountRounded,
findLongestNote,
}

0 comments on commit e2467dd

Please sign in to comment.