Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor sumHoursEntriesSelected
  • Loading branch information
wilc0519 committed Jul 6, 2022
commit a46002dc3d8d725ea2393234a2386ffa06228842
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,8 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
sumHoursEntriesSelected(entry: Entry, checked: boolean){
this.resultSumEntriesSelected = new TotalHours();
const duration = moment.duration(moment(entry.end_date).diff(moment(entry.start_date)));
if(checked){
this.totalTimeSelected = this.totalTimeSelected.add(duration);
}
else{
this.totalTimeSelected = this.totalTimeSelected.subtract(duration);
}
let daysTotalInHours = this.totalTimeSelected.days() * 24;
this.totalTimeSelected = checked ? this.totalTimeSelected.add(duration) : this.totalTimeSelected.subtract(duration);
const daysTotalInHours = this.totalTimeSelected.days() * 24;
this.resultSumEntriesSelected.hours = this.totalTimeSelected.hours() + daysTotalInHours;
Copy link
Contributor

Choose a reason for hiding this comment

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

daysTotalInHours is never reassigned, use 'const' instead of 'let'.

this.resultSumEntriesSelected.minutes = this.totalTimeSelected.minutes();
this.resultSumEntriesSelected.seconds = this.totalTimeSelected.seconds();
Expand Down