Skip to content

Commit 0cee42a

Browse files
committed
fix: make bulk responses use the wakatime spec
1 parent f3d4076 commit 0cee42a

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

rustytime/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rustytime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustytime-server"
33
description = "🕒 blazingly fast time tracking for developers"
4-
version = "0.23.0"
4+
version = "0.23.1"
55
edition = "2024"
66
authors = ["ImShyMike"]
77
readme = "../README.md"

rustytime/src/handlers/api/user.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ async fn process_heartbeat_request(
137137
HeartbeatBulkApiResponse {
138138
responses: stored_results
139139
.into_iter()
140-
.map(|heartbeat| BulkResponseItem(heartbeat, 201))
140+
.map(|heartbeat| {
141+
BulkResponseItem(BulkResponseItemData { data: heartbeat }, 201)
142+
})
141143
.collect(),
142144
},
143145
));

rustytime/src/models/heartbeat/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ pub enum HeartbeatApiResponseVariant {
444444

445445
#[derive(Serialize, Debug, JsonSchema)]
446446
pub struct HeartbeatResponse {
447-
pub id: i64,
447+
pub id: String,
448448
pub entity: String,
449449
#[serde(rename = "type")]
450450
pub type_: String,
@@ -462,7 +462,12 @@ pub struct HeartbeatBulkApiResponse {
462462
}
463463

464464
#[derive(Serialize, Debug, JsonSchema)]
465-
pub struct BulkResponseItem(pub HeartbeatResponse, pub u16);
465+
pub struct BulkResponseItemData {
466+
pub data: HeartbeatResponse,
467+
}
468+
469+
#[derive(Serialize, Debug, JsonSchema)]
470+
pub struct BulkResponseItem(pub BulkResponseItemData, pub u16);
466471

467472
#[derive(Queryable, QueryableByName, Selectable, Serialize, Deserialize, Debug, Clone)]
468473
#[diesel(table_name = heartbeats)]
@@ -720,7 +725,7 @@ impl NewHeartbeat {
720725
impl From<Heartbeat> for HeartbeatResponse {
721726
fn from(heartbeat: Heartbeat) -> Self {
722727
Self {
723-
id: heartbeat.id,
728+
id: heartbeat.id.to_string(),
724729
entity: heartbeat.entity,
725730
type_: heartbeat.type_,
726731
time: datetime_to_f64(heartbeat.time),
@@ -731,7 +736,7 @@ impl From<Heartbeat> for HeartbeatResponse {
731736
impl From<(i64, NewHeartbeat)> for HeartbeatResponse {
732737
fn from((id, heartbeat): (i64, NewHeartbeat)) -> Self {
733738
Self {
734-
id,
739+
id: id.to_string(),
735740
entity: heartbeat.entity,
736741
type_: heartbeat.type_,
737742
time: datetime_to_f64(heartbeat.time),
@@ -742,7 +747,7 @@ impl From<(i64, NewHeartbeat)> for HeartbeatResponse {
742747
impl From<Heartbeat> for BulkResponseItem {
743748
fn from(heartbeat: Heartbeat) -> Self {
744749
let response = HeartbeatResponse::from(heartbeat);
745-
BulkResponseItem(response, 201)
750+
BulkResponseItem(BulkResponseItemData { data: response }, 201)
746751
}
747752
}
748753

rustytime/src/models/heartbeat/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ fn heartbeat_response_conversion_retains_entity_details() {
349349
source_type: None,
350350
};
351351
let response = HeartbeatResponse::from(heartbeat.clone());
352-
assert_eq!(response.id, heartbeat.id);
352+
assert_eq!(response.id, heartbeat.id.to_string());
353353
}
354354

355355
// ============================================================================

0 commit comments

Comments
 (0)