-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
531 additions
and
444 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 16 additions & 49 deletions
65
src/http/controllers/status_controller/non_initialized/model.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,34 @@ | ||
use crate::{ | ||
app::AppContext, persist_operations::data_initializer::load_tasks::InitTableStateSnapshot, | ||
}; | ||
use crate::app::AppContext; | ||
use my_http_server_swagger::*; | ||
use rust_extensions::date_time::DateTimeAsMicroseconds; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Debug, MyHttpObjectStructure)] | ||
pub struct NonInitializedModel { | ||
#[serde(rename = "tablesRemains")] | ||
tables_remains: usize, | ||
#[serde(rename = "tablesTotal")] | ||
tables_total: usize, | ||
#[serde(rename = "tablesLoaded")] | ||
tables_loaded: usize, | ||
#[serde(rename = "filesTotal")] | ||
files_total: usize, | ||
#[serde(rename = "filesLoaded")] | ||
files_loaded: usize, | ||
#[serde(rename = "initializingSeconds")] | ||
initializing_seconds: i64, | ||
progress: Vec<TableProgressModel>, | ||
#[serde(rename = "tableBeingLoadedFiles")] | ||
table_being_loaded_files: Option<String>, | ||
loading_time: i64, | ||
} | ||
|
||
impl NonInitializedModel { | ||
pub async fn new(app: &AppContext) -> Self { | ||
let snapshot = app.init_state.get_snapshot().await; | ||
|
||
let mut progress = Vec::new(); | ||
|
||
let now = DateTimeAsMicroseconds::now(); | ||
|
||
for table_snapshot in snapshot.loading { | ||
progress.push(TableProgressModel::new(table_snapshot)); | ||
} | ||
|
||
return Self { | ||
progress, | ||
tables_remains: snapshot.to_load.len(), | ||
initializing_seconds: now.seconds_before(app.created), | ||
table_being_loaded_files: snapshot.table_being_loaded_files, | ||
}; | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, MyHttpObjectStructure)] | ||
pub struct TableProgressModel { | ||
#[serde(rename = "tableName")] | ||
table_name: String, | ||
#[serde(rename = "toLoad")] | ||
to_load: usize, | ||
loaded: usize, | ||
#[serde(rename = "secondsGone")] | ||
seconds_gone: i64, | ||
} | ||
|
||
impl TableProgressModel { | ||
pub fn new(table_snapshot: InitTableStateSnapshot) -> Self { | ||
let seconds_gone = if let Some(init_started) = table_snapshot.init_started { | ||
let now = DateTimeAsMicroseconds::now(); | ||
now.seconds_before(init_started) | ||
} else { | ||
0 | ||
}; | ||
let snapshot = app.init_state.get_snapshot().await; | ||
|
||
Self { | ||
table_name: table_snapshot.name, | ||
loaded: table_snapshot.loaded, | ||
to_load: table_snapshot.to_load, | ||
seconds_gone, | ||
tables_total: snapshot.tables_total, | ||
files_total: snapshot.files_total, | ||
files_loaded: snapshot.files_loaded, | ||
tables_loaded: snapshot.tables_loaded, | ||
loading_time: now.seconds_before(app.created), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mod persist_io_operations; | ||
mod table_file; | ||
mod with_retries; | ||
pub use persist_io_operations::PersistIoOperations; | ||
pub use persist_io_operations::{PersistIoOperations, TableListOfFilesUploader}; | ||
pub use table_file::TableFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.