From 57de7d2d6140aefb61c0c6a84661f1de9dd53e44 Mon Sep 17 00:00:00 2001 From: jq1836 <95712150+jq1836@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:20:24 +0800 Subject: [PATCH 01/10] Migrate c-ramp.vue to typescript --- frontend/src/components/c-ramp.vue | 65 +++++++++++++++++------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/frontend/src/components/c-ramp.vue b/frontend/src/components/c-ramp.vue index 4c6987b1e6..23721fb637 100644 --- a/frontend/src/components/c-ramp.vue +++ b/frontend/src/components/c-ramp.vue @@ -23,7 +23,7 @@ .ramp__slice( draggable="false", v-for="(slice, j) in user.commits", - v-bind:title="getContributionMessage(slice)", + v-bind:title="getContributionMessage(slice, null)", v-on:click="openTabZoom(user, slice, $event)", v-bind:class="`ramp__slice--color${getSliceColor(slice)}`", v-bind:style="{\ @@ -34,11 +34,13 @@ ) - From b12873c6d124e6a836fd59450143e6cb46e3a1fc Mon Sep 17 00:00:00 2001 From: jq1836 <95712150+jq1836@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:40:20 +0800 Subject: [PATCH 02/10] Fix ramp slice position bug --- frontend/src/components/c-ramp.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/c-ramp.vue b/frontend/src/components/c-ramp.vue index 23721fb637..1724b8bde0 100644 --- a/frontend/src/components/c-ramp.vue +++ b/frontend/src/components/c-ramp.vue @@ -173,12 +173,12 @@ export default defineComponent({ // position for day granularity getSlicePos(date: string) { const total = this.getTotalForPos(this.sdate, this.udate); - return (new Date(this.udate).getMilliseconds() - new Date(date).getMilliseconds()) / (total + window.DAY_IN_MS); + 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, untilDate: string) { - return new Date(untilDate).getMilliseconds() - new Date(sinceDate).getMilliseconds(); + return new Date(untilDate).valueOf() - new Date(sinceDate).valueOf(); }, getRampColor(commit: CommitResult, slice: Commit) { if (this.isDeletesContribution(commit)) { From 06935b05a736ee58e21197e6e13eb497e87dab26 Mon Sep 17 00:00:00 2001 From: jq1836 <95712150+jq1836@users.noreply.github.com> Date: Sat, 23 Sep 2023 15:13:45 +0800 Subject: [PATCH 03/10] Add null to signature of getContributionMessage --- frontend/src/components/c-ramp.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/c-ramp.vue b/frontend/src/components/c-ramp.vue index 1724b8bde0..a424313b0e 100644 --- a/frontend/src/components/c-ramp.vue +++ b/frontend/src/components/c-ramp.vue @@ -125,8 +125,9 @@ export default defineComponent({ const newSize = 100 * (slice.insertions / +this.avgsize); return Math.max(newSize * this.rampSize, 0.5); }, - getContributionMessage(slice: Commit, commit: CommitResult) { - if (this.tframe === 'commit') { + // commit of type CommitResult must be provided if tframe === 'commit', only pass null if tframe !== 'commit + getContributionMessage(slice: Commit, commit: CommitResult | null) { + if (this.tframe === 'commit' && commit !== null) { return `[${slice.date}] ${commit.messageTitle}: +${commit.insertions} -${commit.deletions} lines `; } From 844bf8ebae56a90a62fa16acdb509285cb3d2f0f Mon Sep 17 00:00:00 2001 From: jq1836 <95712150+jq1836@users.noreply.github.com> Date: Sat, 23 Sep 2023 18:06:59 +0800 Subject: [PATCH 04/10] Typecast daily commits --- frontend/src/components/c-ramp.vue | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/frontend/src/components/c-ramp.vue b/frontend/src/components/c-ramp.vue index a424313b0e..40cf7cb185 100644 --- a/frontend/src/components/c-ramp.vue +++ b/frontend/src/components/c-ramp.vue @@ -1,37 +1,37 @@