Skip to content

Commit

Permalink
fix: make total include only billable time
Browse files Browse the repository at this point in the history
  • Loading branch information
Leksat committed Jan 3, 2023
1 parent 1a138ed commit 5f835ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/Summary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Summary tests', () => {
/>,
);
expect(screen.getByTestId('summary').innerHTML).toMatchInlineSnapshot(`
"Total: 17h0m
"Total billable: 16h40m
By project:
A: 5h40m
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('Summary tests', () => {
/>,
);
expect(screen.getByTestId('summary').innerHTML).toMatchInlineSnapshot(`
"Total: 6h0m
"Total billable: 6h0m
By project:
A: 6h0m
Expand Down
9 changes: 7 additions & 2 deletions src/components/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ export const Summary: React.FC<Props> = ({ entries, now }) => {
summaryByDescription[description] += seconds;
}
result =
'Total: ' +
toHumanTime(Object.values(summary).reduce((a, b) => a + b, 0)) +
'Total billable: ' +
toHumanTime(
Object.entries(summary)
.filter(([description]) => description !== '[other]')
.map(([, seconds]) => seconds)
.reduce((a, b) => a + b, 0),
) +
'\n\nBy project:\n' +
Object.entries(summaryByProject)
.sort(([a], [b]) => sort(a, b))
Expand Down

0 comments on commit 5f835ba

Please sign in to comment.