Data view
This commit is contained in:
23
src/tasks/clear_data.rs
Normal file
23
src/tasks/clear_data.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use loco_rs::prelude::*;
|
||||
|
||||
use crate::services;
|
||||
|
||||
pub struct ClearData;
|
||||
|
||||
#[async_trait]
|
||||
impl Task for ClearData {
|
||||
fn task(&self) -> TaskInfo {
|
||||
TaskInfo {
|
||||
name: "clear_data".to_string(),
|
||||
detail: "Task for clearing all data".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn run(&self, app_context: &AppContext, _vars: &task::Vars) -> Result<()> {
|
||||
services::data::clear_all_data(&app_context).await?;
|
||||
|
||||
tracing::info!("All data cleared successfully");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
24
src/tasks/delete_data.rs
Normal file
24
src/tasks/delete_data.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use loco_rs::prelude::*;
|
||||
|
||||
use crate::services;
|
||||
|
||||
pub struct DeleteData;
|
||||
|
||||
#[async_trait]
|
||||
impl Task for DeleteData {
|
||||
fn task(&self) -> TaskInfo {
|
||||
TaskInfo {
|
||||
name: "delete_data".to_string(),
|
||||
detail: "Task for deleting all data".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> {
|
||||
let file_name = vars.cli_arg("name")?;
|
||||
|
||||
services::data::delete_data_by_file_name(&file_name, &app_context).await?;
|
||||
|
||||
tracing::info!("Data file {} deleted successfully", file_name);
|
||||
Ok(())
|
||||
}
|
||||
}
|
@@ -3,3 +3,5 @@ pub mod create_job;
|
||||
pub mod create_skill;
|
||||
pub mod create_user;
|
||||
pub mod seed;
|
||||
pub mod clear_data;
|
||||
pub mod delete_data;
|
Reference in New Issue
Block a user