Skip to content

Commit

Permalink
configurable batch size
Browse files Browse the repository at this point in the history
  • Loading branch information
avoonix committed Aug 1, 2024
1 parent d5f7b23 commit b2b383c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fuzzle/src/background_tasks/periodic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn start_periodic_tasks(
let vector_db = vector_db_clone.clone();
tokio::spawn(async move {
loop {
sleep(Duration::minutes(5).to_std().expect("no overflow")).await;
sleep(Duration::minutes(10).to_std().expect("no overflow")).await;
let span = tracing::info_span!("periodic_refetch_stickers");
let bot = bot.clone();
let database = database.clone();
Expand All @@ -51,7 +51,7 @@ pub fn start_periodic_tasks(
async move {
// TODO: make this configurable
let result = refetch_stickers(
69,
paths.periodic_refetch_batch_size,
database.clone(),
bot.clone(),
paths.clone(),
Expand Down Expand Up @@ -200,13 +200,13 @@ async fn fix_missing_tag_implications(

#[tracing::instrument(skip(database, bot, config, vector_db))]
async fn refetch_stickers(
count: i64,
count: u64,
database: Database,
bot: Bot,
config: Arc<Config>,
vector_db: VectorDatabase,
) -> Result<(), InternalError> {
let set_names = database.get_n_least_recently_fetched_set_ids(count).await?;
let set_names = database.get_n_least_recently_fetched_set_ids(count as i64).await?;
for (i, set_name) in set_names.into_iter().enumerate() {
import_all_stickers_from_set(
&set_name,
Expand Down
2 changes: 2 additions & 0 deletions fuzzle/src/bot/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub struct Config {
pub cache_dir_path: String,
pub db_file_path: String,

pub periodic_refetch_batch_size: u64,

pub bot_display_name: String, // TODO: use this instead of hardcoding
pub greeting_sticker_id: Option<String>,
pub default_blacklist: Vec<String>,
Expand Down
1 change: 1 addition & 0 deletions fuzzle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub async fn init() -> Result<()> {
let settings = config::Config::builder()
// sticker from the set t.me/addstickers/FuzzleBot
.set_default("greeting_sticker_id", "AgADbRIAAhZaEFI")?
.set_default("periodic_refetch_batch_size", 400)?
.set_default(
"default_blacklist",
vec![
Expand Down

0 comments on commit b2b383c

Please sign in to comment.