add max_items_to_process config to limit processing usage

This commit is contained in:
OMGeeky
2024-04-23 21:50:27 +02:00
parent d89ce798e7
commit 2a99247123
2 changed files with 4 additions and 5 deletions

4
Cargo.lock generated
View File

@@ -3000,8 +3000,8 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "twba-backup-config"
version = "0.1.5"
source = "git+https://github.com/OMGeeky/backup_config.git#c42b6fca97502bd3f590f78324cfc9437e5ce20d"
version = "0.1.6"
source = "git+https://github.com/OMGeeky/backup_config.git#60092672b4b45667ef21073b3c43c062715ce486"
dependencies = [
"confique",
"serde",

View File

@@ -3,9 +3,7 @@ use crate::twitch::TwitchClient;
use std::path::Path;
use twba_local_db::prelude::*;
use twba_local_db::re_exports::sea_orm::ActiveValue::Set;
use twba_local_db::re_exports::sea_orm::{
ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel, QueryFilter,
};
use twba_local_db::re_exports::sea_orm::{ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel, QueryFilter, QuerySelect};
#[derive(Debug)]
pub struct DownloaderClient {
@@ -24,6 +22,7 @@ impl DownloaderClient {
Path::new(self.twitch_client.config.download_folder_path.as_str());
let videos = Videos::find()
.filter(VideosColumn::Status.eq(Status::NotStarted))
.limit(self.twitch_client.config.max_items_to_process)
.all(&self.db)
.await?;
info!("Found {} videos to download", videos.len());