Skip to content

Commit

Permalink
Fix heatmap
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Petit authored and Kevin Petit committed May 16, 2020
1 parent dab8c6c commit c5b93bd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 35 deletions.
8 changes: 3 additions & 5 deletions frontend/src/components/Service/ServiceHeatmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,16 @@
},
methods: {
async chartHeatmap() {
let start = new Date(new Date().getUTCFullYear(), new Date().getUTCMonth()-2, 1);
let start = new Date(Date.UTC(new Date().getUTCFullYear(), new Date().getUTCMonth()-2, 1));
let monthData = [];
let monthNum = start.getUTCMonth()
for (let i=1; i<=3; i++) {
let end = this.lastDayOfMonth(monthNum)
window.console.log("getting: ",start, end)
let end = this.lastDayOfMonth(start)
const inputdata = await this.heatmapData(start, end)
monthData.push(inputdata)
start = new Date(start.getUTCFullYear(), start.getUTCMonth()+1, 1);
start = new Date(Date.UTC(start.getUTCFullYear(), start.getUTCMonth()+1, 1));
monthNum += 1
}
this.series = monthData.reverse()
Expand Down
54 changes: 24 additions & 30 deletions frontend/src/mixin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from "vue";
const { zonedTimeToUtc, utcToZonedTime, startOfToday, lastDayOfMonth, subSeconds, parse, getUnixTime, fromUnixTime, differenceInSeconds, formatDistance } = require('date-fns')
const { startOfToday, lastDayOfMonth, subSeconds, getUnixTime, fromUnixTime, differenceInSeconds, formatDistance } = require('date-fns')
import formatDistanceToNow from 'date-fns/formatDistanceToNow'
import format from 'date-fns/format'
import parseISO from 'date-fns/parseISO'
Expand All @@ -19,26 +19,23 @@ export default Vue.mixin({
startToday() {
return startOfToday()
},
secondsHumanize (val) {
const t2 = addSeconds(new Date(0), val)
if (val >= 60) {
let minword = "minute"
if (val >= 120) {
minword = "minutes"
}
return format(t2, "m '"+minword+"' s 'seconds'")
}
return format(t2, "s 'seconds'")
},
secondsHumanize (val) {
const t2 = addSeconds(new Date(0), val)
if (val >= 60) {
let minword = "minute"
if (val >= 120) {
minword = "minutes"
}
return format(t2, "m '"+minword+"' s 'seconds'")
}
return format(t2, "s 'seconds'")
},
utc(val) {
return new Date.UTC(val)
},
ago(t1) {
return formatDistanceToNow(parseISO(t1))
},
daysInMonth(t1) {
return lastDayOfMonth(t1)
},
nowSubtract(seconds) {
return subSeconds(new Date(), seconds)
},
Expand All @@ -51,9 +48,9 @@ export default Vue.mixin({
niceDate(val) {
return format(parseISO(val), "EEEE, MMM do h:mma")
},
parseISO(v) {
return parseISO(v)
},
parseISO(v) {
return parseISO(v)
},
toUnix(val) {
return getUnixTime(val)
},
Expand Down Expand Up @@ -149,17 +146,14 @@ export default Vue.mixin({
})
return {data: newSet}
},
humanTime(val) {
if (val >= 10000) {
return Math.floor(val / 10000) + "ms"
}
return Math.floor(val / 1000) + "μs"
},
lastDayOfMonth(month) {
return new Date(Date.UTC(new Date().getUTCFullYear(), month + 1, 0))
},
firstDayOfMonth(month) {
return new Date(Date.UTC(new Date().getUTCFullYear(), month, 1)).getUTCDate()
}
humanTime(val) {
if (val >= 10000) {
return Math.floor(val / 10000) + "ms"
}
return Math.floor(val / 1000) + "μs"
},
lastDayOfMonth(date) {
return lastDayOfMonth(date)
},
}
});

0 comments on commit c5b93bd

Please sign in to comment.