Skip to content

Commit

Permalink
reduce complexity of total calculation for optimise timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasongg committed Apr 8, 2024
1 parent 8b5fc11 commit 755fde6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions frontend/src/components/c-ramp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,16 @@ export default defineComponent({
if (this.optimisedMinimumDate === null || this.optimisedMaximumDate === null) {
return 0;
}
const total = this.getTotalForPos(this.optimisedMinimumDate, this.optimisedMaximumDate);
const total = this.optimisedMaximumDate - this.optimisedMinimumDate;
return (new Date(this.optimisedMaximumDate).valueOf() - new Date(date).valueOf()) / (total + window.DAY_IN_MS);
}
const total = this.getTotalForPos(this.sdate, this.udate);
return (new Date(this.udate).valueOf() - new Date(date).valueOf()) / (total + window.DAY_IN_MS);
},
// get duration in miliseconds between 2 date
getTotalForPos(sinceDate: string | number, untilDate: string | number) {
return (typeof untilDate === 'string' ? new Date(untilDate).valueOf() : untilDate)
- (typeof sinceDate === 'string' ? new Date(sinceDate).valueOf() : sinceDate);
getTotalForPos(sinceDate: string, untilDate: string) {
return new Date(untilDate).valueOf() - new Date(sinceDate).valueOf();
},
getRampColor(commit: CommitResult, slice: Commit) {
if (this.isDeletesContribution(commit)) {
Expand Down

0 comments on commit 755fde6

Please sign in to comment.