fixed bug that triggered QueryNoRows on state-toc by adding a default value and improved output when QueryNoRows occurs

This commit is contained in:
murmeldin 2025-01-14 17:15:07 +01:00
parent 6611f239f7
commit 1577d5de2e
3 changed files with 9 additions and 2 deletions

View file

@ -46,6 +46,11 @@ pub const CONFIG: CfgGroup<'static> = CfgGroup {
description: description:
"Message-Id of last initial announcement to send In-Reply-To (if applicable).", "Message-Id of last initial announcement to send In-Reply-To (if applicable).",
}, },
CfgField::Default {
key: "state-toc",
default: "error: no toc saved",
description: "Recipient of the emails sent.",
},
], ],
}; };

View file

@ -80,6 +80,7 @@ impl KeyValueStore {
let result = row.get(0)?; let result = row.get(0)?;
Ok(result) Ok(result)
} else { } else {
println!(": Keinen Wert für '{key}' gefunden, bitte Datenbank überprüfen!");
Err(rusqlite::Error::QueryReturnedNoRows) Err(rusqlite::Error::QueryReturnedNoRows)
} }
} }

View file

@ -417,7 +417,7 @@ fn do_reminder(
NYI!("trace/verbose annotations"); NYI!("trace/verbose annotations");
// fetch current pad contents & summarize // fetch current pad contents & summarize
let (current_pad_id, _pad_content, toc, n_topics) = get_pad_info(config, hedgedoc); let (current_pad_id, _pad_content, toc, n_topics) = get_pad_info(config, hedgedoc);
let old_toc = config.get("state-toc")?; let old_toc = config.get("email-state-toc")?;
// construct email // construct email
let human_date = plenum_day.format("%d.%m.%Y"); let human_date = plenum_day.format("%d.%m.%Y");
let subject = if n_topics == 0 { let subject = if n_topics == 0 {
@ -458,6 +458,7 @@ fn do_reminder(
"do we skip ahead to ProgramState::Logged here or do we later add a note to the wiki?" "do we skip ahead to ProgramState::Logged here or do we later add a note to the wiki?"
); );
} }
config.set("state-name", &ProgramState::Reminded.to_string()).ok(); config.set("state-name", &ProgramState::Reminded.to_string()).ok();
config.set("state-toc", &toc).ok(); config.set("state-toc", &toc).ok();
Ok(()) Ok(())
@ -576,7 +577,7 @@ fn do_cleanup(
_wiki: &Mediawiki, _wiki: &Mediawiki,
) -> Result<(), Box<dyn Error>> { ) -> Result<(), Box<dyn Error>> {
NYI!("trace/verbose annotations"); NYI!("trace/verbose annotations");
config.delete("state-toc"); config.delete("email-state-toc");
config.delete("email-last-message-id"); config.delete("email-last-message-id");
NYI!("rotate pad links"); NYI!("rotate pad links");
NYI!("double-check state for leftovers"); NYI!("double-check state for leftovers");