♻️ refactor(core): rename initialise_message_list to initialise_lists

- rename initialise_message_list to initialise_lists for clarity
- update all references to the function with the new name
- the function now initialises both message and label lists
This commit is contained in:
Jeremiah Russell
2025-10-28 16:42:30 +00:00
committed by Jeremiah Russell
parent ed0d7e6bf3
commit bf65721cec
2 changed files with 9 additions and 5 deletions

View File

@@ -497,7 +497,7 @@ async fn run_rules(client: &mut GmailClient, rules: Rules, execute: bool) -> Res
}; };
log::info!("Executing rule `#{}` for label `{label}`", rule.describe()); log::info!("Executing rule `#{}` for label `{label}`", rule.describe());
client.initialise_message_list(); client.initialise_lists();
client.set_rule(rule.clone()); client.set_rule(rule.clone());
client.set_execute(execute); client.set_execute(execute);
if let Err(e) = client.find_rule_and_messages_for_label(&label).await { if let Err(e) = client.find_rule_and_messages_for_label(&label).await {

View File

@@ -196,7 +196,7 @@ pub trait RuleProcessor {
/// in dry-run mode (`false`) before enabling execution. /// in dry-run mode (`false`) before enabling execution.
fn set_execute(&mut self, value: bool); fn set_execute(&mut self, value: bool);
/// Initialises the message list to prepare for application of rule. /// Initialises the message and label lists to prepare for application of rule.
/// ///
/// # Arguments /// # Arguments
/// ///
@@ -221,7 +221,7 @@ pub trait RuleProcessor {
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
fn initialise_message_list(&mut self); fn initialise_lists(&mut self);
/// Configures the end-of-life rule to apply during processing. /// Configures the end-of-life rule to apply during processing.
/// ///
@@ -323,8 +323,9 @@ impl RuleProcessor for GmailClient {
/// on the in-scope messages. /// on the in-scope messages.
/// ///
/// This must be called before processing any labels. /// This must be called before processing any labels.
fn initialise_message_list(&mut self) { fn initialise_lists(&mut self) {
self.messages = Vec::new(); self.messages = Vec::new();
self.label_ids = Vec::new();
} }
/// Configures the end-of-life rule for this Gmail client. /// Configures the end-of-life rule for this Gmail client.
@@ -735,11 +736,13 @@ mod tests {
messages: Vec<MessageSummary>, messages: Vec<MessageSummary>,
rule: Option<EolRule>, rule: Option<EolRule>,
execute: bool, execute: bool,
labels: Vec<String>,
} }
impl RuleProcessor for MockProcessor { impl RuleProcessor for MockProcessor {
fn initialise_message_list(&mut self) { fn initialise_lists(&mut self) {
self.messages = Vec::new(); self.messages = Vec::new();
self.labels = Vec::new();
} }
fn set_rule(&mut self, rule: EolRule) { fn set_rule(&mut self, rule: EolRule) {
@@ -775,6 +778,7 @@ mod tests {
rule: None, rule: None,
execute: false, execute: false,
messages: Vec::new(), messages: Vec::new(),
labels: Vec::new(),
}; };
// Test initial state // Test initial state