fix: fix loss of precision during timestamp convert

This commit is contained in:
imlonghao 2022-02-14 01:03:59 +08:00
parent 3fa809dc71
commit 4bc09184f7
Failed to extract signature
4 changed files with 10 additions and 6 deletions

View file

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed
- Fix loss of precision during timestamp convert
## [0.2.5] - 2022-01-27 ## [0.2.5] - 2022-01-27
### Fixed ### Fixed

View file

@ -36,7 +36,7 @@
data: "updated_at", data: "updated_at",
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
if (type == 'display') { if (type == 'display') {
return DATE_FORMATTER.format(new Date(data * 1000)) return DATE_FORMATTER.format(new Date(data))
} else { } else {
return data return data
} }

View file

@ -99,7 +99,7 @@
data: "ts", data: "ts",
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
if (type == 'display') { if (type == 'display') {
return DATE_FORMATTER.format(new Date(data * 1000)) return DATE_FORMATTER.format(new Date(data))
} else { } else {
return data return data
} }

View file

@ -107,7 +107,7 @@ async fn status(db: web::Data<deadpool_postgres::Pool>) -> impl Responder {
let ts: chrono::DateTime<chrono::Utc> = rows[0].get("ts"); let ts: chrono::DateTime<chrono::Utc> = rows[0].get("ts");
let event: BatchEvent = rows[0].get("event"); let event: BatchEvent = rows[0].get("event");
let result: StatusResponse = StatusResponse { let result: StatusResponse = StatusResponse {
ts: ts.timestamp(), ts: ts.timestamp_millis(),
event: event.to_string(), event: event.to_string(),
}; };
HttpResponse::Ok().json(result) HttpResponse::Ok().json(result)
@ -134,7 +134,7 @@ async fn current(db: web::Data<deadpool_postgres::Pool>) -> impl Responder {
let build_reasons: String = row.get("build_reasons"); let build_reasons: String = row.get("build_reasons");
let elapsed: i32 = row.get("elapsed"); let elapsed: i32 = row.get("elapsed");
result.push(CurrentResponse { result.push(CurrentResponse {
updated_at: updated_at.timestamp(), updated_at: updated_at.timestamp_millis(),
pkgbase: pkgbase, pkgbase: pkgbase,
status: build_status.to_string(), status: build_status.to_string(),
reasons: build_reasons, reasons: build_reasons,
@ -169,7 +169,7 @@ async fn logs(db: web::Data<deadpool_postgres::Pool>) -> impl Responder {
let memory: pg_bigdecimal::PgNumeric = row.get("memory"); let memory: pg_bigdecimal::PgNumeric = row.get("memory");
let memory_bd: bigdecimal::BigDecimal = memory.n.unwrap(); let memory_bd: bigdecimal::BigDecimal = memory.n.unwrap();
results.push(LogsResponse { results.push(LogsResponse {
ts: ts.timestamp(), ts: ts.timestamp_millis(),
pkgbase: pkgbase, pkgbase: pkgbase,
pkg_version: pkg_version, pkg_version: pkg_version,
maintainer: maintainer, maintainer: maintainer,
@ -207,7 +207,7 @@ async fn get_pkg(
let memory: pg_bigdecimal::PgNumeric = row.get("memory"); let memory: pg_bigdecimal::PgNumeric = row.get("memory");
let memory_bd: bigdecimal::BigDecimal = memory.n.unwrap(); let memory_bd: bigdecimal::BigDecimal = memory.n.unwrap();
results.push(LogsResponse { results.push(LogsResponse {
ts: ts.timestamp(), ts: ts.timestamp_millis(),
pkgbase: pkgbase, pkgbase: pkgbase,
pkg_version: pkg_version, pkg_version: pkg_version,
maintainer: maintainer, maintainer: maintainer,