Skip to content

Commit

Permalink
Sort locally persisted operations
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Mar 11, 2022
1 parent bbf7e51 commit c3464df
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use dashmap::DashMap;
use persist_query::PersistError;
use relay_config::LocalPersistConfig;
use sha1::{Digest, Sha1};
use std::collections::BTreeMap;

use crate::OperationPersister;

Expand Down Expand Up @@ -53,7 +54,13 @@ impl OperationPersister for LocalPersister {
}

fn finalize(&self) -> Result<(), PersistError> {
let content = serde_json::to_string_pretty(&self.query_map)?;
let ordered: BTreeMap<_, _> = self
.query_map
.iter()
.map(|x| (x.key().clone(), x.value().clone()))
.collect();

let content = serde_json::to_string_pretty(&ordered)?;
std::fs::write(&self.config.file, content)?;

Ok(())
Expand Down

0 comments on commit c3464df

Please sign in to comment.