mirror of
https://codeberg.org/YGGverse/ytd.git
synced 2026-04-08 04:55:26 +00:00
count processed items only
This commit is contained in:
parent
d650683079
commit
af874ea32b
1 changed files with 12 additions and 5 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -53,15 +53,21 @@ async fn main() {
|
|||
items.len(),
|
||||
channel.items_limit
|
||||
);
|
||||
for (i, item) in items.into_iter().enumerate() {
|
||||
let mut items_processed = 0; // items that match config conditions only
|
||||
for item in items {
|
||||
if !channel_item_id_regex.is_match(&item.id) {
|
||||
panic!(
|
||||
"API returned unexpected item ID `{}` for channel `{c}`; unsafe to continue as used in the exec context",
|
||||
&item.id
|
||||
)
|
||||
}
|
||||
if channel.items_limit.is_some_and(|l| i >= l) {
|
||||
debug!("items limit for channel `{c}` reached at {i}; break.");
|
||||
if channel
|
||||
.items_limit
|
||||
.is_some_and(|limit| items_processed >= limit)
|
||||
{
|
||||
debug!(
|
||||
"processed items limit for channel `{c}` reached at {items_processed}; break."
|
||||
);
|
||||
break;
|
||||
}
|
||||
if channel
|
||||
|
|
@ -134,10 +140,11 @@ async fn main() {
|
|||
}) {
|
||||
match database.process(&item.id) {
|
||||
Ok(()) => {
|
||||
items_processed += 1;
|
||||
info!(
|
||||
"exec `{cmd}` for channel `{c}` successful."
|
||||
);
|
||||
debug!("stdout: `{response:?}`");
|
||||
debug!("stdout: `{response:?}`")
|
||||
}
|
||||
Err(e) => panic!(
|
||||
"can't persist processed item `{}` for channel `{c}` by `{cmd}`: `{e}`",
|
||||
|
|
@ -198,7 +205,7 @@ fn cmd(command: &config::Command) {
|
|||
.all(|s| String::from_utf8_lossy(&response.stdout).contains(s))
|
||||
}) {
|
||||
info!("exec `{}` successful.", command.exec);
|
||||
debug!("stdout: `{response:?}`");
|
||||
debug!("stdout: `{response:?}`")
|
||||
} else {
|
||||
panic!("unexpected exec result `{}`: `{response:?}`", command.exec)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue