Skip to content

Commit

Permalink
Optimize loading media item details (#365)
Browse files Browse the repository at this point in the history
* fix(backend): incorrect average rating being displayed

* feat(frontend): load media specifics in a different query

* refactor(frontend): change query names

* refactor(frontend): move image data to secondary query

* fix(frontend): remove allow features

* build(backend): bump version

* fix(frontend): do not wait for user media details to load
  • Loading branch information
IgnisDa authored Sep 25, 2023
1 parent edbfc29 commit 389ab50
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 184 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ryot"
version = "2.18.5"
version = "2.18.6"
edition = "2021"
repository = "https://github.com/IgnisDa/ryot"
license = "GPL-V3"
Expand Down
11 changes: 7 additions & 4 deletions apps/backend/src/miscellaneous/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1695,10 +1695,13 @@ impl MiscellaneousService {
let average_rating = if reviews.is_empty() {
None
} else {
Some(
reviews.iter().flat_map(|r| r.rating).sum::<Decimal>()
/ Decimal::from(reviews.len()),
)
let total_rating = reviews.iter().flat_map(|r| r.rating).collect_vec();
let sum = total_rating.iter().sum::<Decimal>();
if sum == dec!(0) {
None
} else {
Some(sum / Decimal::from(total_rating.iter().len()))
}
};

Ok(UserMediaDetails {
Expand Down
Loading

0 comments on commit 389ab50

Please sign in to comment.