mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
fix the task view and forward the task db size
This commit is contained in:
parent
eb4bdde432
commit
8a23e707c1
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user