summaryrefslogtreecommitdiffstats
path: root/crate_db/src/lib_crate_db.rs
diff options
context:
space:
mode:
authorKornel <kornel@geekhood.net>2020-03-03 00:22:15 +0000
committerKornel <kornel@geekhood.net>2020-03-03 00:42:10 +0000
commitc1f1ab4b809f6a802a06fb9b828602e91c5961d2 (patch)
tree76bfcd9f0c045ef8289c3e27a349ca87416935fe /crate_db/src/lib_crate_db.rs
parent340c0baec9416254e6a728f503b69f1327c4c24a (diff)
Deep slug check
Diffstat (limited to 'crate_db/src/lib_crate_db.rs')
-rw-r--r--crate_db/src/lib_crate_db.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crate_db/src/lib_crate_db.rs b/crate_db/src/lib_crate_db.rs
index 7fb11fb..725df95 100644
--- a/crate_db/src/lib_crate_db.rs
+++ b/crate_db/src/lib_crate_db.rs
@@ -432,7 +432,7 @@ impl CrateDb {
fn extract_crate_categories(&self, conn: &Connection, c: &CrateVersionData<'_>, keywords: impl Iterator<Item=String>, is_important_ish: bool) -> FResult<(Vec<(f64, f64, String)>, bool)> {
let (explicit_categories, invalid_categories): (Vec<_>, Vec<_>) = c.category_slugs.iter().map(|c| c.to_string())
.partition(|slug| {
- categories::CATEGORIES.from_slug(&slug).next().is_some() // FIXME: that checks top level only
+ categories::CATEGORIES.from_slug(&slug).1
});
let had_explicit_categories = !explicit_categories.is_empty();
@@ -463,7 +463,7 @@ impl CrateDb {
// slightly nudge towards specific, leaf categories over root generic ones
for (w, slug) in &mut categories {
- *w *= categories::CATEGORIES.from_slug(slug).last().map(|c| c.preference as f64).unwrap_or(1.);
+ *w *= categories::CATEGORIES.from_slug(slug).0.last().map(|c| c.preference as f64).unwrap_or(1.);
}
let max_weight = categories.iter().map(|&(w, _)| w)