|
|
@@ -269,23 +269,28 @@ impl FlowCells {
|
|
|
/// # Arguments
|
|
|
/// * `new_cells` - A vector of parsed `FlowCell` instances.
|
|
|
pub fn insert_flowcells(&mut self, new_cells: Vec<FlowCell>) {
|
|
|
- let mut map: HashMap<String, FlowCell> = self
|
|
|
- .flow_cells
|
|
|
- .drain(..)
|
|
|
- .map(|fc| (fc.sample_sheet.flow_cell_id.clone(), fc))
|
|
|
- .collect();
|
|
|
-
|
|
|
+ // let mut map: HashMap<String, FlowCell> = self
|
|
|
+ // .flow_cells
|
|
|
+ // .drain(..)
|
|
|
+ // .map(|fc| {
|
|
|
+ // (fc.sample_sheet.flow_cell_id.clone(), fc)
|
|
|
+ // })
|
|
|
+ // .collect();
|
|
|
+ //
|
|
|
for fc in new_cells {
|
|
|
- map.entry(fc.sample_sheet.flow_cell_id.clone())
|
|
|
- .and_modify(|existing| {
|
|
|
- if fc.modified > existing.modified {
|
|
|
- *existing = fc.clone();
|
|
|
- }
|
|
|
- })
|
|
|
- .or_insert(fc);
|
|
|
+ self.flow_cells.push(fc);
|
|
|
+ // map.entry(fc.sample_sheet.flow_cell_id.clone())
|
|
|
+ // .and_modify(|existing| {
|
|
|
+ // if fc.modified > existing.modified {
|
|
|
+ // *existing = fc.clone();
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // .or_insert(fc);
|
|
|
}
|
|
|
+ self.sort_by_modified();
|
|
|
+ self.flow_cells.dedup_by_key(|fc| fc.id());
|
|
|
|
|
|
- self.flow_cells = map.into_values().collect();
|
|
|
+ // self.flow_cells = map.into_values().collect();
|
|
|
}
|
|
|
|
|
|
/// Discover new archived flowcells in `archive_dir` and update the JSON at `store_path`.
|
|
|
@@ -324,7 +329,7 @@ impl FlowCells {
|
|
|
files,
|
|
|
) {
|
|
|
Ok(fc) => {
|
|
|
- // merge & dedupe
|
|
|
+ // merge & dedup
|
|
|
self.insert_flowcells(vec![fc]);
|
|
|
}
|
|
|
Err(e) => {
|
|
|
@@ -480,6 +485,13 @@ impl FlowCell {
|
|
|
throughput,
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ pub fn id(&self) -> String {
|
|
|
+ match &self.experiment {
|
|
|
+ FlowCellExperiment::WGSPod5Mux(p) => p,
|
|
|
+ FlowCellExperiment::WGSPod5Demux(p) => p,
|
|
|
+ }.to_string()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// Describes the type of experiment layout based on `.pod5` file structure.
|