memory optimization and queue fix

This commit is contained in:
Per Stark
2025-01-14 13:41:36 +01:00
parent 560249e5ae
commit f666607198
5 changed files with 15 additions and 19 deletions

View File

@@ -40,9 +40,6 @@ impl ContentProcessor {
}
pub async fn process(&self, content: &TextContent) -> Result<(), AppError> {
// Store original content
store_item(&self.db_client, content.clone()).await?;
let now = Instant::now();
// Perform analyis, this step also includes retrieval
@@ -65,6 +62,9 @@ impl ContentProcessor {
self.store_vector_chunks(content),
)?;
// Store original content
store_item(&self.db_client, content.to_owned()).await?;
self.db_client.rebuild_indexes().await?;
Ok(())
}

View File

@@ -1,6 +1,9 @@
use chrono::Utc;
use futures::Stream;
use std::sync::Arc;
use std::{
sync::Arc,
time::{SystemTime, UNIX_EPOCH},
};
use surrealdb::{opt::PatchOp, Error, Notification};
use tracing::{error, info};
@@ -75,7 +78,10 @@ impl JobQueue {
.db
.update((Job::table_name(), id))
.patch(PatchOp::replace("/status", status))
.patch(PatchOp::replace("/updated_at", Utc::now()))
.patch(PatchOp::replace(
"/updated_at",
surrealdb::sql::Datetime::default(),
))
.await?;
Ok(job)
@@ -90,7 +96,6 @@ impl JobQueue {
/// Get unfinished jobs, ie newly created and in progress up two times
pub async fn get_unfinished_jobs(&self) -> Result<Vec<Job>, AppError> {
info!("Getting unfinished jobs");
let jobs: Vec<Job> = self
.db
.query(