Repository: meilisearch/meilisearch
File: dump/src/reader/v4/mod.rs (Rust)

Code before:

impl V4IndexReader {
    pub fn new(
        name: String,
        path: &Path,
        index_metadata: &IndexMeta,
        tasks: BufReader<File>,
    ) -> Result<Self> {
        let meta = File::open(path.join("meta.json"))?;
        let meta: DumpMeta = serde_json::from_reader(meta)?;

        let mut created_at = None;
        let mut updated_at = None;

        for line in tasks.lines() {
            let task: Task = serde_json::from_str(&line?)?;

            if task.index_uid.to_string() == name {
                // The first task to match our index_uid that succeeded (ie. processed_at returns Some)
                // is our `last_updated_at`.
                if updated_at.is_none() {
                    updated_at = task.processed_at()
                }

                // Once we reach the `creation_task_id` we can stop iterating on the task queue and
                // this task represent our `created_at`.
                if task.id as usize == index_metadata.creation_task_id {
                    created_at = task.created_at();
                    break;
                }
            }
        }

        let metadata = IndexMetadata {
            uid: name,
            primary_key: meta.primary_key,
            created_at: created_at.unwrap_or_else(OffsetDateTime::now_utc),
            updated_at: updated_at.unwrap_or_else(OffsetDateTime::now_utc),
        };

        let ret = V4IndexReader {
            metadata,
            settings: meta.settings.check(),
            documents: BufReader::new(File::open(path.join("documents.jsonl"))?),
        };

        Ok(ret)
    }

    pub fn metadata(&self) -> &IndexMetadata {
        &self.metadata

Review comment (suggestion):
typo

```suggestion
                // this task represents our `created_at`.
```

Code after:

impl V4IndexReader {
    pub fn new(
        name: String,
        path: &Path,
        index_metadata: &IndexMeta,
        tasks: BufReader<File>,
    ) -> Result<Self> {
        let meta = File::open(path.join("meta.json"))?;
        let meta: DumpMeta = serde_json::from_reader(meta)?;

        let mut created_at = None;
        let mut updated_at = None;

        for line in tasks.lines() {
            let task: Task = serde_json::from_str(&line?)?;

            if task.index_uid.to_string() == name {
                // The first task to match our index_uid that succeeded (ie. processed_at returns Some)
                // is our `last_updated_at`.
                if updated_at.is_none() {
                    updated_at = task.processed_at()
                }

                // Once we reach the `creation_task_id` we can stop iterating on the task queue and
                // this task represents our `created_at`.
                if task.id as usize == index_metadata.creation_task_id {
                    created_at = task.created_at();
                    break;
                }
            }
        }

        let current_time = OffsetDateTime::now_utc();

        let metadata = IndexMetadata {
            uid: name,
            primary_key: meta.primary_key,
            created_at: created_at.unwrap_or(current_time),
            updated_at: updated_at.unwrap_or(current_time),
        };

        let ret = V4IndexReader {
            metadata,
            settings: meta.settings.check(),
            documents: BufReader::new(File::open(path.join("documents.jsonl"))?),
        };

        Ok(ret)
    }