bug fixed

This commit is contained in:
병준 박 2022-08-18 23:35:24 +00:00
parent e1cf3ebd54
commit 2584bf8a55
3 changed files with 116 additions and 151 deletions

View File

@ -64,33 +64,6 @@ impl Scheduler {
Ok(()) Ok(())
} }
async fn add_history(
&'static self,
item: String,
start_at: i64,
code: i64,
message: Option<String>,
) -> Result<(), Box<dyn std::error::Error>> {
let conn = self.pool.get().expect("conn");
let complete_at = (chrono::Utc::now()).timestamp();
self
.synchronization_history_repository
.insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item,
start_at,
complete_at,
code,
message,
},
)
.expect("synchronization_history insert");
Ok(())
}
async fn balance_for_user(&'static self) -> Result<(), Box<dyn std::error::Error>> { async fn balance_for_user(&'static self) -> Result<(), Box<dyn std::error::Error>> {
let j_synchronization = Job::new_async("0 0 0/1 * * *", move |_uuid, _l| { let j_synchronization = Job::new_async("0 0 0/1 * * *", move |_uuid, _l| {
Box::pin(async move { Box::pin(async move {
@ -122,28 +95,38 @@ impl Scheduler {
} }
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_BALANCE_USER.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_BALANCE_USER.to_string(),
start_at, start_at,
0, complete_at: (chrono::Utc::now()).timestamp(),
None, code: 0,
message: None,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
Ok::<(), api::core::models::Error>(()) Ok::<(), api::core::models::Error>(())
} }
.await .await
{ {
let conn = self.pool.get().expect("conn");
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_BALANCE_USER.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_BALANCE_USER.to_string(),
start_at, start_at,
e.code, complete_at: (chrono::Utc::now()).timestamp(),
e.msg.clone(), code: e.code,
message: e.msg,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
} }
}) })
})?; })?;
@ -197,28 +180,37 @@ impl Scheduler {
} }
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_BALANCE_USER.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_BALANCE_PARTNER.to_string(),
start_at, start_at,
0, complete_at: (chrono::Utc::now()).timestamp(),
None, code: 0,
message: None,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
Ok::<(), api::core::models::Error>(()) Ok::<(), api::core::models::Error>(())
} }
.await .await
{ {
let conn = self.pool.get().expect("conn");
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_BALANCE_USER.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_BALANCE_PARTNER.to_string(),
start_at, start_at,
e.code, complete_at: (chrono::Utc::now()).timestamp(),
e.msg.clone(), code: e.code,
message: e.msg,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
} }
}) })
})?; })?;

View File

@ -63,33 +63,6 @@ impl Scheduler {
Ok(()) Ok(())
} }
async fn add_history(
&'static self,
item: String,
start_at: i64,
code: i64,
message: Option<String>,
) -> Result<(), Box<dyn std::error::Error>> {
let complete_at = (chrono::Utc::now()).timestamp();
let conn = self.pool.get().expect("conn");
self
.synchronization_history_repository
.insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item,
start_at,
complete_at,
code,
message,
},
)
.expect("synchronization_history insert");
Ok(())
}
async fn list_vendors(&'static self) -> Result<(), Box<dyn std::error::Error>> { async fn list_vendors(&'static self) -> Result<(), Box<dyn std::error::Error>> {
let j_synchronization = Job::new_async("0 0 0/1 * * *", move |_uuid, _l| { let j_synchronization = Job::new_async("0 0 0/1 * * *", move |_uuid, _l| {
Box::pin(async move { Box::pin(async move {
@ -124,14 +97,18 @@ impl Scheduler {
.expect("vendor upsert"); .expect("vendor upsert");
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_VENDORS.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_VENDORS.to_string(),
start_at, start_at,
0, complete_at: (chrono::Utc::now()).timestamp(),
None, code: 0,
message: None,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
self.list_games().await; self.list_games().await;
@ -139,15 +116,20 @@ impl Scheduler {
} }
.await .await
{ {
let conn = self.pool.get().expect("conn");
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_VENDORS.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_VENDORS.to_string(),
start_at, start_at,
e.code, complete_at: (chrono::Utc::now()).timestamp(),
e.msg.clone(), code: e.code,
message: e.msg,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
} }
}) })
})?; })?;
@ -203,28 +185,37 @@ impl Scheduler {
.expect("game upsert"); .expect("game upsert");
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_GAMES.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_GAMES.to_string(),
start_at, start_at,
0, complete_at: (chrono::Utc::now()).timestamp(),
None, code: 0,
message: None,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
Ok::<(), api::core::models::Error>(()) Ok::<(), api::core::models::Error>(())
} }
.await .await
{ {
let conn = self.pool.get().expect("conn");
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_GAMES.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_GAMES.to_string(),
start_at, start_at,
e.code, complete_at: (chrono::Utc::now()).timestamp(),
e.msg.clone(), code: e.code,
message: e.msg,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
} }
} }
} }

View File

@ -59,33 +59,6 @@ impl Scheduler {
Ok(()) Ok(())
} }
async fn add_history(
&'static self,
item: String,
start_at: i64,
code: i64,
message: Option<String>,
) -> Result<(), Box<dyn std::error::Error>> {
let conn = self.pool.get().expect("conn");
let complete_at = (chrono::Utc::now()).timestamp();
self
.synchronization_history_repository
.insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item,
start_at,
complete_at,
code,
message,
},
)
.expect("synchronization_history insert");
Ok(())
}
async fn list_members(&'static self) -> Result<(), Box<dyn std::error::Error>> { async fn list_members(&'static self) -> Result<(), Box<dyn std::error::Error>> {
let j_synchronization = Job::new_async("0 0 0/1 * * *", move |_uuid, _l| { let j_synchronization = Job::new_async("0 0 0/1 * * *", move |_uuid, _l| {
Box::pin(async move { Box::pin(async move {
@ -111,28 +84,37 @@ impl Scheduler {
} }
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_MEMBERS.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_MEMBERS.to_string(),
start_at, start_at,
0, complete_at: (chrono::Utc::now()).timestamp(),
None, code: 0,
message: None,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
Ok::<(), api::core::models::Error>(()) Ok::<(), api::core::models::Error>(())
} }
.await .await
{ {
let conn = self.pool.get().expect("conn");
self self
.add_history( .synchronization_history_repository
repositories::synchronization::models::ITEM_MEMBERS.to_string(), .insert(
&conn,
&repositories::synchronization_history::models::NewSynchronizationHistory {
item: repositories::synchronization::models::ITEM_MEMBERS.to_string(),
start_at, start_at,
e.code, complete_at: (chrono::Utc::now()).timestamp(),
e.msg.clone(), code: e.code,
message: e.msg,
},
) )
.await .expect("synchronization_history insert");
.expect("add_history");
} }
}) })
})?; })?;