Skip to content

Commit

Permalink
Merge branch 'development' into feature/request-headers-stream-proxying
Browse files Browse the repository at this point in the history
  • Loading branch information
elpiel committed Oct 10, 2023
2 parents 6316e00 + d12b689 commit 696c22d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/models/library_by_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn catalogs_update<F: LibraryFilter>(
let r#type = catalog
.first()
.and_then(|first_page| first_page.first())
.map(|library_item| &library_item.r#type)
.map(|library_item| library_item.r#type.as_str())
.expect("first page of library catalog is empty");
let size = catalog.iter().fold(0, |result, page| result + page.len());
result.insert(r#type, size);
Expand All @@ -158,16 +158,19 @@ fn catalogs_update<F: LibraryFilter>(
.items
.values()
.filter(|library_item| F::predicate(library_item, notifications))
.fold(HashMap::new(), |mut result, library_item| {
result
.entry(&library_item.r#type)
.or_insert_with(Vec::new)
.push(library_item.to_owned());
result
})
.fold(
HashMap::<&str, Vec<LibraryItem>>::new(),
|mut result, library_item| {
result
.entry(&library_item.r#type)
.or_default()
.push(library_item.to_owned());
result
},
)
.into_iter()
.sorted_by(|(a_type, _), (b_type, _)| {
compare_with_priorities(a_type.as_str(), b_type.as_str(), &*TYPE_PRIORITIES)
compare_with_priorities(*a_type, *b_type, &*TYPE_PRIORITIES)
})
.rev()
.map(|(r#type, library_items)| {
Expand Down

0 comments on commit 696c22d

Please sign in to comment.