aboutsummaryrefslogtreecommitdiff
path: root/import/src/reporting.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-02-19 18:36:01 +0100
committermetamuffin <metamuffin@disroot.org>2026-02-19 18:36:01 +0100
commit768688e34073e7430d92293fb0a995c7dc24cdf5 (patch)
tree76b954bb765f5723b0fb909dad8a584b5b5ce64f /import/src/reporting.rs
parent3a81f654a9f49649fb6755b6e35649f0102a9572 (diff)
downloadjellything-768688e34073e7430d92293fb0a995c7dc24cdf5.tar
jellything-768688e34073e7430d92293fb0a995c7dc24cdf5.tar.bz2
jellything-768688e34073e7430d92293fb0a995c7dc24cdf5.tar.zst
display import stages in admin ui
Diffstat (limited to 'import/src/reporting.rs')
-rw-r--r--import/src/reporting.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/import/src/reporting.rs b/import/src/reporting.rs
index 61bd623..631be65 100644
--- a/import/src/reporting.rs
+++ b/import/src/reporting.rs
@@ -15,6 +15,7 @@ pub static IMPORT_PROGRESS: RwLock<Option<ImportProgress>> = RwLock::const_new(N
#[derive(Debug, Serialize, Clone)]
pub struct ImportProgress {
+ pub stage: String,
pub total_items: usize,
pub finished_items: usize,
pub tasks: Vec<String>,
@@ -23,6 +24,7 @@ pub struct ImportProgress {
pub(crate) fn start_import() {
*IMPORT_ERRORS.blocking_write() = Vec::new();
*IMPORT_PROGRESS.blocking_write() = Some(ImportProgress {
+ stage: "Initializing".to_string(),
total_items: 0,
finished_items: 0,
tasks: vec!["idle".to_string(); current_num_threads()],
@@ -32,6 +34,24 @@ pub(crate) fn end_import() {
*IMPORT_PROGRESS.blocking_write() = None;
}
+pub(crate) fn set_stage(name: String, total: usize) {
+ if let Some(p) = IMPORT_PROGRESS.blocking_write().as_mut() {
+ p.stage = name;
+ p.total_items = total;
+ p.finished_items = 0;
+ }
+}
+pub(crate) fn inc_finished() {
+ if let Some(p) = IMPORT_PROGRESS.blocking_write().as_mut() {
+ p.finished_items += 1;
+ }
+}
+pub(crate) fn inc_total() {
+ if let Some(p) = IMPORT_PROGRESS.blocking_write().as_mut() {
+ p.total_items += 1;
+ }
+}
+
pub(crate) fn set_task(task: String) {
let thread = current_thread_index().unwrap_or(0);
debug!("T#{thread:<3}| {task}");