Skip to content

Commit 48f54d6

Browse files
Merge pull request #359 from TropicalDog17/fix-358
Fix: Include quest completion timestamp in get_quest_participants response
2 parents 00b0897 + be7664e commit 48f54d6

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ regex = "1.10.0"
3232
ctor = "0.2.6"
3333
axum-client-ip = "0.4.0"
3434
jsonwebtoken = "9"
35-
tower = "0.4.13"
35+
tower = "0.4.13"

src/endpoints/admin/quest/get_quest_participants.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ pub async fn get_quest_participants_handler(
5858
doc! { "$match": { "task_id": { "$in": &task_ids } } },
5959
doc! { "$group": {
6060
"_id": "$address",
61-
"task_ids": { "$addToSet": "$task_id" }
61+
"task_ids": { "$addToSet": "$task_id" },
62+
"max_timestamp": { "$max": "$timestamp" }
6263
}},
6364
doc! { "$project": {
6465
"address": "$_id",
65-
"tasks_completed_count": { "$size": "$task_ids" }
66+
"tasks_completed_count": { "$size": "$task_ids" },
67+
"quest_completion_timestamp": "$max_timestamp"
6668
}},
6769
];
6870

@@ -83,13 +85,21 @@ pub async fn get_quest_participants_handler(
8385
Err(_) => continue, // Skip invalid documents
8486
};
8587

88+
let timestamp = match doc.get_i64("quest_completion_timestamp") {
89+
Ok(ts) => ts,
90+
Err(_) => continue, // Skip invalid documents
91+
};
92+
8693
let tasks_completed_count: usize = match doc.get_i32("tasks_completed_count") {
8794
Ok(count) => count as usize,
8895
Err(_) => continue, // Skip invalid documents
8996
};
9097

9198
if tasks_completed_count == total_tasks {
92-
participants.push(address);
99+
participants.push(json!({
100+
"address": address,
101+
"quest_completion_timestamp": timestamp,
102+
}));
93103
}
94104
}
95105
Err(e) => return get_error(format!("Error processing aggregation results: {}", e)),

0 commit comments

Comments
 (0)