+
Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

tweak search settings #523

Merged
merged 3 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ and `Removed`.
- Optional 'Categories' column for Catalog.
- Optional 'Summary' column for My Addons.

## Changed

- Tweaked catalog fuzzy search to weight title matches higher than description
matches

## [0.7.0] - 2021-01-26

### Added
Expand Down
20 changes: 13 additions & 7 deletions src/gui/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2474,20 +2474,26 @@ fn query_and_sort_catalog(ajour: &mut Ajour) {
.iter()
.filter(|a| !a.game_versions.is_empty())
.filter_map(|a| {
let title_and_summary = format!("{} {}", a.name, a.summary);

if let Some(query) = &query {
if let Some(score) = fuzzy_matcher.fuzzy_match(&title_and_summary, &query) {
Some((a, score))
let title_score = fuzzy_matcher
.fuzzy_match(&a.name, &query)
.unwrap_or_default();
let description_score = fuzzy_matcher
.fuzzy_match(&a.summary, &query)
.unwrap_or_default()
/ 2;

let max_score = title_score.max(description_score);

if max_score > 0 {
Some((a, max_score))
} else {
None
}
} else {
Some((a, 1))
Some((a, 0))
}
})
// Only return positive scores
.filter(|(_, s)| *s > 0)
.filter(|(a, _)| {
a.game_versions
.iter()
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载