mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 05:14: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,
|
update_file_path: PathBuf,
|
||||||
indexes_path: PathBuf,
|
indexes_path: PathBuf,
|
||||||
dumps_path: PathBuf,
|
dumps_path: PathBuf,
|
||||||
|
task_db_size: usize,
|
||||||
index_size: usize,
|
index_size: usize,
|
||||||
indexer_config: IndexerConfig,
|
indexer_config: IndexerConfig,
|
||||||
autobatching_enabled: bool,
|
autobatching_enabled: bool,
|
||||||
@ -285,6 +286,7 @@ impl IndexScheduler {
|
|||||||
|
|
||||||
let mut options = heed::EnvOpenOptions::new();
|
let mut options = heed::EnvOpenOptions::new();
|
||||||
options.max_dbs(9);
|
options.max_dbs(9);
|
||||||
|
options.map_size(task_db_size);
|
||||||
|
|
||||||
let env = options.open(tasks_path)?;
|
let env = options.open(tasks_path)?;
|
||||||
let file_store = FileStore::new(&update_file_path)?;
|
let file_store = FileStore::new(&update_file_path)?;
|
||||||
@ -834,6 +836,7 @@ mod tests {
|
|||||||
tempdir.path().join("indexes"),
|
tempdir.path().join("indexes"),
|
||||||
tempdir.path().join("dumps"),
|
tempdir.path().join("dumps"),
|
||||||
1024 * 1024,
|
1024 * 1024,
|
||||||
|
1024 * 1024,
|
||||||
IndexerConfig::default(),
|
IndexerConfig::default(),
|
||||||
autobatching, // enable autobatching
|
autobatching, // enable autobatching
|
||||||
sender,
|
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("update_files"),
|
||||||
opt.db_path.join("indexes"),
|
opt.db_path.join("indexes"),
|
||||||
opt.dumps_dir.clone(),
|
opt.dumps_dir.clone(),
|
||||||
|
opt.max_task_db_size.get_bytes() as usize,
|
||||||
opt.max_index_size.get_bytes() as usize,
|
opt.max_index_size.get_bytes() as usize,
|
||||||
(&opt.indexer_options).try_into()?,
|
(&opt.indexer_options).try_into()?,
|
||||||
true,
|
true,
|
||||||
|
@ -48,25 +48,13 @@ pub struct TaskView {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub error: Option<ResponseError>,
|
pub error: Option<ResponseError>,
|
||||||
|
|
||||||
#[serde(
|
#[serde(serialize_with = "serialize_duration", default)]
|
||||||
serialize_with = "serialize_duration",
|
|
||||||
skip_serializing_if = "Option::is_none",
|
|
||||||
default
|
|
||||||
)]
|
|
||||||
pub duration: Option<Duration>,
|
pub duration: Option<Duration>,
|
||||||
#[serde(with = "time::serde::rfc3339")]
|
#[serde(with = "time::serde::rfc3339")]
|
||||||
pub enqueued_at: OffsetDateTime,
|
pub enqueued_at: OffsetDateTime,
|
||||||
#[serde(
|
#[serde(with = "time::serde::rfc3339::option", default)]
|
||||||
with = "time::serde::rfc3339::option",
|
|
||||||
skip_serializing_if = "Option::is_none",
|
|
||||||
default
|
|
||||||
)]
|
|
||||||
pub started_at: Option<OffsetDateTime>,
|
pub started_at: Option<OffsetDateTime>,
|
||||||
#[serde(
|
#[serde(with = "time::serde::rfc3339::option", default)]
|
||||||
with = "time::serde::rfc3339::option",
|
|
||||||
skip_serializing_if = "Option::is_none",
|
|
||||||
default
|
|
||||||
)]
|
|
||||||
pub finished_at: Option<OffsetDateTime>,
|
pub finished_at: Option<OffsetDateTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,6 +354,14 @@ async fn delete_tasks(
|
|||||||
Ok(HttpResponse::Ok().json(task_view))
|
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(
|
async fn get_tasks(
|
||||||
index_scheduler: GuardedData<ActionPolicy<{ actions::TASKS_GET }>, Data<IndexScheduler>>,
|
index_scheduler: GuardedData<ActionPolicy<{ actions::TASKS_GET }>, Data<IndexScheduler>>,
|
||||||
params: web::Query<TasksFilterQuery>,
|
params: web::Query<TasksFilterQuery>,
|
||||||
@ -439,14 +435,7 @@ async fn get_tasks(
|
|||||||
|
|
||||||
let from = tasks_results.first().map(|t| t.uid);
|
let from = tasks_results.first().map(|t| t.uid);
|
||||||
|
|
||||||
// TODO: TAMO: define a structure to represent this type
|
let tasks = AllTasks { results: tasks_results, limit: limit.saturating_sub(1), from, next };
|
||||||
let tasks = json!({
|
|
||||||
"results": tasks_results,
|
|
||||||
"limit": limit.saturating_sub(1),
|
|
||||||
"from": from,
|
|
||||||
"next": next,
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().json(tasks))
|
Ok(HttpResponse::Ok().json(tasks))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user