INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: revisiting album average rating-taking into account non rated tracks  (Read 315 times)

zeltak

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 480

Hi all

I have searched (and found!) many good posts here on different ways (both simple and uber sophisticated) to calculate a user filed with the mean rating of an album.

yet I cant see anyway to do so while taking into account non rated tracks.

What I would love is to consider unrated tracks as `1` and take that into account when calculating average album ratings

anyone has done something like this before?

kind regards

Z
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2422
Re: revisiting album average rating-taking into account non rated tracks
« Reply #1 on: December 15, 2023, 06:53:51 pm »

Solution 1:

A single FieldQuery() almost gets you there, but unfortunately it ignores empty values. So the expression needs to be more complicated in order to generate the missing ratings:
Code: [Select]
save(ItemCount(/[Artist - Album /(Year/)/]), _count)/
save(FieldQuery(Artist - Album /(Year/), [Artist - Album (Year)], Rating, 1, 1), _ratings)/
save(1, _noRating)/
FormatNumber(Math((listmath([_ratings],2) + ([_count]-listcount([_ratings])) * [_noRating]) / [_count]),1)

This may be too slow if you have a large library. For most cases, it will work fine and much faster if you use 'Current View' Scope mode in FieldQuery() - just change this line:
Code: [Select]
save(FieldQuery(Artist - Album /(Year/), [Artist - Album (Year)], Rating, 1, 0), _ratings)/
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2422
Re: revisiting album average rating-taking into account non rated tracks
« Reply #2 on: December 15, 2023, 06:57:47 pm »

Solution 2 (simpler):

- create a calculated field called [RatingOr1] with expression: FirstNotEmpty([Rating,0],1)
- Use this expression for the album average:
Code: [Select]
FormatNumber(ListMath(FieldQuery(Artist - Album /(Year/), [Artist - Album (Year)], RatingOr1, 1, 1),3),1)

Again, try it with the Scope=0 to see if it works for you as it's faster:
Code: [Select]
FormatNumber(ListMath(FieldQuery(Artist - Album /(Year/), [Artist - Album (Year)], RatingOr1, 1, 0),3),1)
Logged

zeltak

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 480
Re: revisiting album average rating-taking into account non rated tracks
« Reply #3 on: December 16, 2023, 12:37:13 pm »

wow thx so mych @zybex!!

I tried both methods and both with the `Scope=0` and with both as you said MC comes to a crawl :) (using latest OSX and MBP with m1pro chip)

I wonder is the slow crawl persistent or does MC calculates the mean rating as a one off thing and then stores this in file tags?

thx so much again

Z
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2422
Re: revisiting album average rating-taking into account non rated tracks
« Reply #4 on: December 16, 2023, 03:03:37 pm »

Yeah, Fieldquery can be slow :( One way to go about it is use/show it only on Views having few albums, like only when displaying all albums for a given artist. Even so, if your collection is huge then it will be slow regardless.

I think MC caches the results for 1 minute only, so it's not persistent.

If you have a windows machine available, you can use ZStats to pre-calculate the ratings - you can configure it to just run an expression on all files, and re-run it daily/nightly to update the numbers:
https://yabb.jriver.com/interact/index.php/topic,131845.0.html
Logged
Pages: [1]   Go Up