ingestion-pipeline crated init, begun moving

This commit is contained in:
Per Stark
2025-03-06 15:29:13 +01:00
parent d156f9e48e
commit 812bce27d1
21 changed files with 648 additions and 601 deletions

View File

@@ -12,7 +12,7 @@ use tracing::info;
use common::{
error::{AppError, HtmlError},
storage::types::{
file_info::FileInfo, job::Job, knowledge_entity::KnowledgeEntity,
file_info::FileInfo, ingestion_task::IngestionTask, knowledge_entity::KnowledgeEntity,
knowledge_relationship::KnowledgeRelationship, text_chunk::TextChunk,
text_content::TextContent, user::User,
},
@@ -26,7 +26,7 @@ page_data!(IndexData, "index/index.html", {
gdpr_accepted: bool,
user: Option<User>,
latest_text_contents: Vec<TextContent>,
active_jobs: Vec<Job>
active_jobs: Vec<IngestionTask>
});
pub async fn index_handler(
@@ -39,9 +39,11 @@ pub async fn index_handler(
let gdpr_accepted = auth.current_user.is_some() | session.get("gdpr_accepted").unwrap_or(false);
let active_jobs = match auth.current_user.is_some() {
true => User::get_unfinished_jobs(&auth.current_user.clone().unwrap().id, &state.db)
.await
.map_err(|e| HtmlError::new(e, state.templates.clone()))?,
true => {
User::get_unfinished_ingestion_tasks(&auth.current_user.clone().unwrap().id, &state.db)
.await
.map_err(|e| HtmlError::new(e, state.templates.clone()))?
}
false => vec![],
};
@@ -172,7 +174,7 @@ async fn get_and_validate_text_content(
#[derive(Serialize)]
pub struct ActiveJobsData {
pub active_jobs: Vec<Job>,
pub active_jobs: Vec<IngestionTask>,
pub user: User,
}
@@ -190,7 +192,7 @@ pub async fn delete_job(
.await
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;
let active_jobs = User::get_unfinished_jobs(&user.id, &state.db)
let active_jobs = User::get_unfinished_ingestion_tasks(&user.id, &state.db)
.await
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;
@@ -216,7 +218,7 @@ pub async fn show_active_jobs(
None => return Ok(Redirect::to("/signin").into_response()),
};
let active_jobs = User::get_unfinished_jobs(&user.id, &state.db)
let active_jobs = User::get_unfinished_ingestion_tasks(&user.id, &state.db)
.await
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;

View File

@@ -12,8 +12,10 @@ use tracing::info;
use common::{
error::{AppError, HtmlError, IntoHtmlError},
ingress::ingress_object::IngressObject,
storage::types::{file_info::FileInfo, job::Job, user::User},
storage::types::{
file_info::FileInfo, ingestion_payload::IngestionPayload, ingestion_task::IngestionTask,
user::User,
},
};
use crate::{
@@ -112,7 +114,7 @@ pub async fn process_ingress_form(
}))
.await?;
let ingress_objects = IngressObject::create_ingress_objects(
let payloads = IngestionPayload::create_ingestion_payload(
input.content,
input.instructions,
input.category,
@@ -121,9 +123,11 @@ pub async fn process_ingress_form(
)
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;
let futures: Vec<_> = ingress_objects
let futures: Vec<_> = payloads
.into_iter()
.map(|object| Job::create_and_add_to_db(object.clone(), user.id.clone(), &state.db))
.map(|object| {
IngestionTask::create_and_add_to_db(object.clone(), user.id.clone(), &state.db)
})
.collect();
try_join_all(futures)
@@ -132,7 +136,7 @@ pub async fn process_ingress_form(
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;
// Update the active jobs page with the newly created job
let active_jobs = User::get_unfinished_jobs(&user.id, &state.db)
let active_jobs = User::get_unfinished_ingestion_tasks(&user.id, &state.db)
.await
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;