feat(service): Plugins may define a priority for their results
Adds an additional parameter for prioritizing the search results from a specific plugin. The plugin may define a priority which will sort results after the initial pattern search. The web plugin will be the first plugin to utilize this feature
This commit is contained in:
parent
454ce19f08
commit
8987565a2a
4 changed files with 36 additions and 1 deletions
|
|
@ -454,6 +454,24 @@ impl<O: Write> Service<O> {
|
|||
other => other,
|
||||
}
|
||||
});
|
||||
|
||||
active_search.sort_by(|a, b| {
|
||||
let plug1 = match plugins.get(a.0) {
|
||||
Some(plug) => plug,
|
||||
None => return Ordering::Greater,
|
||||
};
|
||||
|
||||
let plug2 = match plugins.get(b.0) {
|
||||
Some(plug) => plug,
|
||||
None => return Ordering::Less,
|
||||
};
|
||||
|
||||
plug1
|
||||
.config
|
||||
.query
|
||||
.priority
|
||||
.cmp(&plug2.config.query.priority)
|
||||
})
|
||||
}
|
||||
|
||||
let take = if last_query.starts_with('/') | last_query.starts_with('~') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue