mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
Fix task serialization
This commit is contained in:
parent
3a48de136e
commit
ae174c2cca
3 changed files with 31 additions and 24 deletions
|
@ -31,7 +31,7 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<MeiliSearch> {
|
|||
|
||||
// disable autobatching?
|
||||
AUTOBATCHING_ENABLED.store(
|
||||
opt.scheduler_options.disable_auto_batching,
|
||||
!opt.scheduler_options.disable_auto_batching,
|
||||
std::sync::atomic::Ordering::Relaxed,
|
||||
);
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ pub struct TaskView {
|
|||
#[serde(serialize_with = "time::serde::rfc3339::option::serialize")]
|
||||
finished_at: Option<OffsetDateTime>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
batch_uid: Option<Option<BatchId>>,
|
||||
batch_uid: Option<BatchId>,
|
||||
}
|
||||
|
||||
impl From<Task> for TaskView {
|
||||
|
@ -380,15 +380,15 @@ impl From<Task> for TaskView {
|
|||
|
||||
let duration = finished_at.zip(started_at).map(|(tf, ts)| (tf - ts));
|
||||
|
||||
let batch_uid = if AUTOBATCHING_ENABLED.load(std::sync::atomic::Ordering::Relaxed) {
|
||||
let id = events.iter().find_map(|e| match e {
|
||||
TaskEvent::Batched { batch_id, .. } => Some(*batch_id),
|
||||
_ => None,
|
||||
});
|
||||
Some(id)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let batch_uid = AUTOBATCHING_ENABLED
|
||||
.load(std::sync::atomic::Ordering::Relaxed)
|
||||
.then(|| {
|
||||
events.iter().find_map(|e| match e {
|
||||
TaskEvent::Batched { batch_id, .. } => Some(*batch_id),
|
||||
_ => None,
|
||||
})
|
||||
})
|
||||
.flatten();
|
||||
|
||||
Self {
|
||||
uid: id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue