fix the task view and forward the task db size

This commit is contained in:
Irevoire 2022-10-23 11:23:24 +02:00 committed by Clément Renault
parent eb4bdde432
commit 8a23e707c1
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
3 changed files with 16 additions and 23 deletions

View File

@ -273,6 +273,7 @@ impl IndexScheduler {
update_file_path: PathBuf,
indexes_path: PathBuf,
dumps_path: PathBuf,
task_db_size: usize,
index_size: usize,
indexer_config: IndexerConfig,
autobatching_enabled: bool,
@ -285,6 +286,7 @@ impl IndexScheduler {
let mut options = heed::EnvOpenOptions::new();
options.max_dbs(9);
options.map_size(task_db_size);
let env = options.open(tasks_path)?;
let file_store = FileStore::new(&update_file_path)?;
@ -834,6 +836,7 @@ mod tests {
tempdir.path().join("indexes"),
tempdir.path().join("dumps"),
1024 * 1024,
1024 * 1024,
IndexerConfig::default(),
autobatching, // enable autobatching
sender,

View File

@ -114,6 +114,7 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(IndexScheduler, AuthContr
opt.db_path.join("update_files"),
opt.db_path.join("indexes"),
opt.dumps_dir.clone(),
opt.max_task_db_size.get_bytes() as usize,
opt.max_index_size.get_bytes() as usize,
(&opt.indexer_options).try_into()?,
true,

View File

@ -48,25 +48,13 @@ pub struct TaskView {
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<ResponseError>,
#[serde(
serialize_with = "serialize_duration",
skip_serializing_if = "Option::is_none",
default
)]
#[serde(serialize_with = "serialize_duration", default)]
pub duration: Option<Duration>,
#[serde(with = "time::serde::rfc3339")]
pub enqueued_at: OffsetDateTime,
#[serde(
with = "time::serde::rfc3339::option",
skip_serializing_if = "Option::is_none",
default
)]
#[serde(with = "time::serde::rfc3339::option", default)]
pub started_at: Option<OffsetDateTime>,
#[serde(
with = "time::serde::rfc3339::option",
skip_serializing_if = "Option::is_none",
default
)]
#[serde(with = "time::serde::rfc3339::option", default)]
pub finished_at: Option<OffsetDateTime>,
}
@ -366,6 +354,14 @@ async fn delete_tasks(
Ok(HttpResponse::Ok().json(task_view))
}
#[derive(Debug, Serialize)]
pub struct AllTasks {
results: Vec<TaskView>,
limit: u32,
from: Option<u32>,
next: Option<u32>,
}
async fn get_tasks(
index_scheduler: GuardedData<ActionPolicy<{ actions::TASKS_GET }>, Data<IndexScheduler>>,
params: web::Query<TasksFilterQuery>,
@ -439,14 +435,7 @@ async fn get_tasks(
let from = tasks_results.first().map(|t| t.uid);
// TODO: TAMO: define a structure to represent this type
let tasks = json!({
"results": tasks_results,
"limit": limit.saturating_sub(1),
"from": from,
"next": next,
});
let tasks = AllTasks { results: tasks_results, limit: limit.saturating_sub(1), from, next };
Ok(HttpResponse::Ok().json(tasks))
}