Skip to content

Commit

Permalink
feat: update types
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtom committed Mar 6, 2024
1 parent c5d72e6 commit e68b5cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/models.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use mongodb::{bson, Database};
use mongodb::bson::DateTime;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use starknet::{
Expand Down Expand Up @@ -54,7 +53,7 @@ pub_struct!(Deserialize; CompletedTasks {
pub struct CompletedTaskDocument {
address: String,
task_id: u32,
timestamp: DateTime,
timestamp: i64,
}

pub_struct!(Serialize; Reward {
Expand Down Expand Up @@ -95,7 +94,7 @@ pub_struct!(Deserialize; VerifyAchievementQuery {
pub_struct!(Debug, Serialize, Deserialize; AchievedDocument {
addr: String,
achievement_id: u32,
timestamp:DateTime,
timestamp:i64,
});

pub_struct!(Debug, Serialize, Deserialize; AchievementDocument {
Expand Down
7 changes: 4 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ impl CompletedTasksTrait for AppState {
) -> Result<UpdateResult, mongodb::error::Error> {
let completed_tasks_collection: Collection<CompletedTasks> =
self.db.collection("completed_tasks");
let timestamp = Utc::now().timestamp_millis() as f64;
let created_at = Utc::now().timestamp_millis();
let filter = doc! { "address": addr.to_string(), "task_id": task_id };
let update = doc! { "$setOnInsert": { "address": addr.to_string(), "task_id": task_id , "timestamp":timestamp} };
let update = doc! { "$setOnInsert": { "address": addr.to_string(), "task_id": task_id , "timestamp":created_at} };
let options = UpdateOptions::builder().upsert(true).build();

let result = completed_tasks_collection
Expand Down Expand Up @@ -292,10 +292,11 @@ impl AchievementsTrait for AppState {
achievement_id: u32,
) -> Result<UpdateResult, mongodb::error::Error> {
let achieved_collection: Collection<CompletedTasks> = self.db.collection("achieved");
let created_at = Utc::now().timestamp_millis();
let filter = doc! { "addr": addr.to_string(), "achievement_id": achievement_id };
let timestamp = Utc::now().timestamp_millis() as f64;
let update =
doc! { "$setOnInsert": { "addr": addr.to_string(), "achievement_id": achievement_id , "timestamp":timestamp } };
doc! { "$setOnInsert": { "addr": addr.to_string(), "achievement_id": achievement_id , "timestamp":created_at } };
let options = UpdateOptions::builder().upsert(true).build();

let result = achieved_collection
Expand Down

0 comments on commit e68b5cb

Please sign in to comment.