Repository: meilisearch/meilisearch
File: dump/src/reader/v3/updates.rs (Rust)

Code before:
    pub fn processed(&self) -> Option<&Processed> {
        match self {
            UpdateStatus::Processed(p) => Some(p),
            _ => None,
        }
    }

    pub fn created_at(&self) -> Option<OffsetDateTime> {
        match self {
            UpdateStatus::Processing(u) => Some(u.from.enqueued_at.clone()),
            UpdateStatus::Enqueued(u) => Some(u.enqueued_at.clone()),
            UpdateStatus::Processed(u) => Some(u.from.from.enqueued_at.clone()),
            UpdateStatus::Aborted(u) => Some(u.from.enqueued_at.clone()),
            UpdateStatus::Failed(u) => Some(u.from.from.enqueued_at.clone()),
        }
    }

    pub fn processed_at(&self) -> Option<OffsetDateTime> {
        match self {
            UpdateStatus::Processing(u) => Some(u.started_processing_at.clone()),
            UpdateStatus::Enqueued(_) => None,
            UpdateStatus::Processed(u) => Some(u.processed_at.clone()),
            UpdateStatus::Aborted(_) => None,
            UpdateStatus::Failed(u) => Some(u.failed_at.clone()),
        }
    }
}

#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(test, derive(serde::Serialize))]
#[serde(rename_all = "camelCase")]
pub struct Enqueued {
    pub update_id: u64,
    pub meta: Update,
    #[serde(with = "time::serde::rfc3339")]
    pub enqueued_at: OffsetDateTime,
}

impl Enqueued {
    pub fn meta(&self) -> &Update {
        &self.meta
    }

    pub fn id(&self) -> u64 {
        self.update_id
    }
}

#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(test, derive(serde::Serialize))]
#[serde(rename_all = "camelCase")]

Review comment (bug):
I don’t think we need this function anymore 🤔 
But if we do it shouldn’t return something when a task was still **processing** I think.

Also since you return the date when the task was failed it would probably be more accurate to rename it to `finished_at` or somethin’

Code after:
    pub fn processed(&self) -> Option<&Processed> {
        match self {
            UpdateStatus::Processed(p) => Some(p),
            _ => None,
        }
    }

    pub fn enqueued_at(&self) -> Option<OffsetDateTime> {
        match self {
            UpdateStatus::Processing(u) => Some(u.from.enqueued_at),
            UpdateStatus::Enqueued(u) => Some(u.enqueued_at),
            UpdateStatus::Processed(u) => Some(u.from.from.enqueued_at),
            UpdateStatus::Aborted(u) => Some(u.from.enqueued_at),
            UpdateStatus::Failed(u) => Some(u.from.from.enqueued_at),
        }
    }

    pub fn finished_at(&self) -> Option<OffsetDateTime> {
        match self {
            UpdateStatus::Processing(_) => None,
            UpdateStatus::Enqueued(_) => None,
            UpdateStatus::Processed(u) => Some(u.processed_at),
            UpdateStatus::Aborted(_) => None,
            UpdateStatus::Failed(u) => Some(u.failed_at),
        }
    }
}

#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(test, derive(serde::Serialize))]
#[serde(rename_all = "camelCase")]
pub struct Enqueued {
    pub update_id: u64,
    pub meta: Update,
    #[serde(with = "time::serde::rfc3339")]
    pub enqueued_at: OffsetDateTime,
}

impl Enqueued {
    pub fn meta(&self) -> &Update {
        &self.meta
    }

    pub fn id(&self) -> u64 {
        self.update_id
    }
}

#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(test, derive(serde::Serialize))]
#[serde(rename_all = "camelCase")]