Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
9fc1aae5b5 | |||
9bcf0a8b12 | |||
690c50754b |
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
|||||||
VERSION:=$(shell git describe --always)
|
VERSION:=$(shell git describe --always)
|
||||||
TARGET_ENV=dev
|
TARGET_ENV?=dev
|
||||||
|
|
||||||
build: dist/personal-measure-api.tar.gz dist/personal-measure-web.tar.gz
|
build: dist/personal-measure-api.tar.gz dist/personal-measure-web.tar.gz
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import json, macros, options, sequtils, strutils, times, timeutils, unicode,
|
import json, macros, options, sequtils, strutils, times, timeutils, unicode,
|
||||||
uuids
|
uuids
|
||||||
|
|
||||||
|
import nre except toSeq
|
||||||
|
|
||||||
const UNDERSCORE_RUNE = "_".toRunes[0]
|
const UNDERSCORE_RUNE = "_".toRunes[0]
|
||||||
const PG_TIMESTAMP_FORMATS = [
|
const PG_TIMESTAMP_FORMATS = [
|
||||||
"yyyy-MM-dd HH:mm:sszz",
|
"yyyy-MM-dd HH:mm:sszz",
|
||||||
"yyyy-MM-dd HH:mm:ss'.'fzz",
|
|
||||||
"yyyy-MM-dd HH:mm:ss'.'ffzz",
|
|
||||||
"yyyy-MM-dd HH:mm:ss'.'fffzz"
|
"yyyy-MM-dd HH:mm:ss'.'fffzz"
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -72,6 +72,19 @@ proc parsePGDatetime*(val: string): DateTime =
|
|||||||
for df in PG_TIMESTAMP_FORMATS:
|
for df in PG_TIMESTAMP_FORMATS:
|
||||||
try: return val.parse(df)
|
try: return val.parse(df)
|
||||||
except: errStr &= "\n" & getCurrentExceptionMsg()
|
except: errStr &= "\n" & getCurrentExceptionMsg()
|
||||||
|
|
||||||
|
# PostgreSQL does not pad the millisecond value in a datetime out to three
|
||||||
|
# decimal points. If this is a value like `2019-09-29 12:00:00.5Z` We need to
|
||||||
|
# manually catch this and pad it out to something like
|
||||||
|
# `2019-09-29 12:00:00.500Z` so that we can parse it.
|
||||||
|
const millisTruncDatePattern = "(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.)(\\d{1,2})(.*)"
|
||||||
|
let match = val.match(re(millisTruncDatePattern))
|
||||||
|
if match.isSome:
|
||||||
|
let captures = match.get.captures
|
||||||
|
let reformatted = captures[0] & captures[1].alignLeft(3, '0') & captures[2]
|
||||||
|
try: return reformatted.parse(PG_TIMESTAMP_FORMATS[1])
|
||||||
|
except: errStr &= "\n" & getCurrentExceptionMsg()
|
||||||
|
|
||||||
raise newException(ValueError, "Cannot parse PG date. Tried:" & errStr)
|
raise newException(ValueError, "Cannot parse PG date. Tried:" & errStr)
|
||||||
|
|
||||||
proc parseDbArray*(val: string): seq[string] =
|
proc parseDbArray*(val: string): seq[string] =
|
||||||
|
@ -1 +1 @@
|
|||||||
const PM_API_VERSION* = "0.5.0"
|
const PM_API_VERSION* = "0.6.0"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "personal-measure-web",
|
"name": "personal-measure-web",
|
||||||
"version": "0.5.0",
|
"version": "0.6.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
|
@ -22,11 +22,13 @@ export class SimpleDetails extends Vue {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private get measurementChartData(): ApexAxisChartSeries {
|
private get measurementChartData(): ApexAxisChartSeries {
|
||||||
const measurementData = this.measurements || [];
|
const measurementData = this.measurements.slice() || [];
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
name: this.measure.name,
|
name: this.measure.name,
|
||||||
data: measurementData.map((m) => ({ x: m.timestamp.toISOString(), y: m.value }))
|
data: measurementData
|
||||||
|
.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime())
|
||||||
|
.map((m) => ({ x: m.timestamp.toISOString(), y: m.value }))
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,13 @@ export class SimpleSummaryGraph extends Vue {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private get measurementData(): ApexAxisChartSeries {
|
private get measurementData(): ApexAxisChartSeries {
|
||||||
const measurementData = this.measurements || [];
|
let measurementData = this.measurements.slice() || [];
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
name: this.measure.name,
|
name: this.measure.name,
|
||||||
data: measurementData.map((m) => ({ x: m.timestamp.toISOString(), y: m.value }))
|
data: measurementData
|
||||||
|
.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime())
|
||||||
|
.map((m) => ({ x: m.timestamp.toISOString(), y: m.value }))
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user