feat: improvement
This commit is contained in:
18 files changed
+2538
-108
No files matched your search
@@ -75,6 +75,12 @@ pub struct Catalog {
|
||||
pub entries: Vec<Entry>,
|
||||
/// Bank metadata by bank id.
|
||||
pub banks: BTreeMap<String, crate::bank::BankMeta>,
|
||||
/// The statistics, loaded from `analysis/` rather than from the banks.
|
||||
///
|
||||
/// Each entry's [`crate::item::Item::calibration`] is filled from this at
|
||||
/// load, so everything downstream reads one item and does not have to know
|
||||
/// that the numbers and the wording come from different files.
|
||||
pub calibration: crate::calibration::CalibrationFile,
|
||||
/// Map from global id to index into `entries`.
|
||||
index: BTreeMap<String, usize>,
|
||||
}
|
||||
@@ -104,7 +110,10 @@ impl Catalog {
|
||||
entries: Vec::new(),
|
||||
banks: BTreeMap::new(),
|
||||
index: BTreeMap::new(),
|
||||
calibration: crate::calibration::CalibrationFile::default(),
|
||||
};
|
||||
catalog.calibration =
|
||||
crate::calibration::CalibrationFile::load(&catalog.layout.calibration_file())?;
|
||||
|
||||
let mut problems = Vec::new();
|
||||
let mut files = yaml::list_yaml(&catalog.layout.banks())?;
|
||||
@@ -145,6 +154,15 @@ impl Catalog {
|
||||
if !problems.is_empty() {
|
||||
return Err(Error::Invalid(problems));
|
||||
}
|
||||
// Statistics are attached here rather than parsed from the bank, which
|
||||
// is why an item can be read as one thing while its wording and its
|
||||
// evidence live in files with different review cycles.
|
||||
for entry in &mut catalog.entries {
|
||||
if let Some(calibration) = catalog.calibration.items.get(&entry.uid) {
|
||||
entry.item.calibration = Some(calibration.clone());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(catalog)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user