Change the format of custom ranking rules when importing v2 dumps

This commit is contained in:
Kerollmops 2021-09-08 11:43:10 +02:00
parent 331d28102f
commit be50b2bec6
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
3 changed files with 52 additions and 15 deletions

View file

@ -439,3 +439,17 @@ pub async fn get_arc_ownership_blocking<T>(mut item: Arc<T>) -> T {
}
}
}
/// Parses the v1 version of the Asc ranking rules `asc(price)`and returns the field name.
pub fn asc_ranking_rule(text: &str) -> Option<&str> {
text.split_once("asc(")
.and_then(|(_, tail)| tail.rsplit_once(")"))
.map(|(field, _)| field)
}
/// Parses the v1 version of the Desc ranking rules `asc(price)`and returns the field name.
pub fn desc_ranking_rule(text: &str) -> Option<&str> {
text.split_once("desc(")
.and_then(|(_, tail)| tail.rsplit_once(")"))
.map(|(field, _)| field)
}