hive-c0re: rfc3339 timestamps on dashboard api + sse json
This commit is contained in:
parent
cf3ac49729
commit
bac2c0a65e
6 changed files with 23 additions and 8 deletions
|
|
@ -89,6 +89,7 @@ impl AuditOutcome {
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct AuditEntry {
|
pub struct AuditEntry {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
pub ts_unix: i64,
|
pub ts_unix: i64,
|
||||||
/// Agent on whose behalf the action was taken.
|
/// Agent on whose behalf the action was taken.
|
||||||
pub agent: String,
|
pub agent: String,
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,9 @@ pub struct PendingReminder {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub file_path: Option<String>,
|
pub file_path: Option<String>,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
pub due_at: i64,
|
pub due_at: i64,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
pub created_at: i64,
|
pub created_at: i64,
|
||||||
/// Most recent delivery failure for this row, if any. Cleared
|
/// Most recent delivery failure for this row, if any. Cleared
|
||||||
/// to NULL on operator retry. Surfaced inline in the dashboard
|
/// to NULL on operator retry. Surfaced inline in the dashboard
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,8 @@ struct ApprovalHistoryView {
|
||||||
sha_short: Option<String>,
|
sha_short: Option<String>,
|
||||||
/// `approved` / `denied` / `failed`.
|
/// `approved` / `denied` / `failed`.
|
||||||
status: &'static str,
|
status: &'static str,
|
||||||
/// Unix seconds. Renders as a relative time on the dashboard.
|
/// RFC 3339 UTC. Renders as a relative time on the dashboard.
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
resolved_at: i64,
|
resolved_at: i64,
|
||||||
/// Operator-supplied deny reason (for `denied`) or build error
|
/// Operator-supplied deny reason (for `denied`) or build error
|
||||||
/// (for `failed`). None on `approved`.
|
/// (for `failed`). None on `approved`.
|
||||||
|
|
@ -471,8 +472,10 @@ struct ApprovalView {
|
||||||
/// `None` for every other kind.
|
/// `None` for every other kind.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
commit_ref: Option<String>,
|
commit_ref: Option<String>,
|
||||||
/// Unix seconds the approval was queued. Rendered as a relative
|
/// RFC 3339 UTC time the approval was queued. Rendered as a
|
||||||
/// time on the card so the operator can spot a stale request.
|
/// relative time on the card so the operator can spot a stale
|
||||||
|
/// request.
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
requested_at: i64,
|
requested_at: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1373,7 +1376,7 @@ async fn api_operator_inbox(State(state): State<AppState>) -> Response {
|
||||||
"id": id,
|
"id": id,
|
||||||
"from": from,
|
"from": from,
|
||||||
"body": body,
|
"body": body,
|
||||||
"at": at,
|
"at": hive_sh4re::wire_time::to_iso(at),
|
||||||
"in_reply_to": in_reply_to,
|
"in_reply_to": in_reply_to,
|
||||||
"file_refs": file_refs,
|
"file_refs": file_refs,
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ pub enum DashboardEvent {
|
||||||
from: String,
|
from: String,
|
||||||
to: String,
|
to: String,
|
||||||
body: String,
|
body: String,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
at: i64,
|
at: i64,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
in_reply_to: Option<i64>,
|
in_reply_to: Option<i64>,
|
||||||
|
|
@ -53,6 +54,7 @@ pub enum DashboardEvent {
|
||||||
from: String,
|
from: String,
|
||||||
to: String,
|
to: String,
|
||||||
body: String,
|
body: String,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
at: i64,
|
at: i64,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
in_reply_to: Option<i64>,
|
in_reply_to: Option<i64>,
|
||||||
|
|
@ -95,6 +97,7 @@ pub enum DashboardEvent {
|
||||||
sha_short: Option<String>,
|
sha_short: Option<String>,
|
||||||
/// `"approved"` / `"denied"` / `"failed"`.
|
/// `"approved"` / `"denied"` / `"failed"`.
|
||||||
status: &'static str,
|
status: &'static str,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
resolved_at: i64,
|
resolved_at: i64,
|
||||||
note: Option<String>,
|
note: Option<String>,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
|
|
@ -111,7 +114,9 @@ pub enum DashboardEvent {
|
||||||
question: String,
|
question: String,
|
||||||
options: Vec<String>,
|
options: Vec<String>,
|
||||||
multi: bool,
|
multi: bool,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
asked_at: i64,
|
asked_at: i64,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso_opt")]
|
||||||
deadline_at: Option<i64>,
|
deadline_at: Option<i64>,
|
||||||
target: Option<String>,
|
target: Option<String>,
|
||||||
/// Verified file-path tokens that appear in `question`.
|
/// Verified file-path tokens that appear in `question`.
|
||||||
|
|
@ -130,6 +135,7 @@ pub enum DashboardEvent {
|
||||||
id: i64,
|
id: i64,
|
||||||
answer: String,
|
answer: String,
|
||||||
answerer: String,
|
answerer: String,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
answered_at: i64,
|
answered_at: i64,
|
||||||
cancelled: bool,
|
cancelled: bool,
|
||||||
target: Option<String>,
|
target: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,14 @@ pub struct OpQuestion {
|
||||||
pub question: String,
|
pub question: String,
|
||||||
pub options: Vec<String>,
|
pub options: Vec<String>,
|
||||||
pub multi: bool,
|
pub multi: bool,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||||
pub asked_at: i64,
|
pub asked_at: i64,
|
||||||
/// Absolute unix-seconds deadline after which a watchdog auto-
|
/// Deadline after which a watchdog auto-resolves the question with
|
||||||
/// resolves the question with answer `[expired]`. `None` = no
|
/// answer `[expired]`. `None` = no expiry. Surfaced on the
|
||||||
/// expiry. Surfaced on the dashboard as a remaining-time chip.
|
/// dashboard as a remaining-time chip.
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso_opt")]
|
||||||
pub deadline_at: Option<i64>,
|
pub deadline_at: Option<i64>,
|
||||||
|
#[serde(with = "hive_sh4re::wire_time::iso_opt")]
|
||||||
pub answered_at: Option<i64>,
|
pub answered_at: Option<i64>,
|
||||||
pub answer: Option<String>,
|
pub answer: Option<String>,
|
||||||
/// Recipient of the question. `None` = the operator (dashboard
|
/// Recipient of the question. `None` = the operator (dashboard
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
//! (keep the usual `default` + `skip_serializing_if` attributes).
|
//! (keep the usual `default` + `skip_serializing_if` attributes).
|
||||||
|
|
||||||
use chrono::{DateTime, SecondsFormat, Utc};
|
use chrono::{DateTime, SecondsFormat, Utc};
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::Deserialize;
|
||||||
|
|
||||||
/// Format unix-epoch seconds as an RFC 3339 UTC string with a `Z`
|
/// Format unix-epoch seconds as an RFC 3339 UTC string with a `Z`
|
||||||
/// suffix. Out-of-range values (never produced by our clocks) clamp to
|
/// suffix. Out-of-range values (never produced by our clocks) clamp to
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue