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 505 times)

zeltak

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

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: 2530
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: 2530
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: 489
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: 2530
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

zeltak

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

Hi again

@zybex coming back to this. as this was so slow and i could not implement this, can one somehow calculate and save the values in a file field? would this make things work reliably?

best

Z
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2530

You can do that with ZStats, as mentioned above.

- create the calculated [RatingOr1] field as mentioned above
- create a normal field called eg. [AlbumRating] to hold the result
- enter this code into the [RunAfter] section of ZStats.ini:

Code: [Select]
setfield(AlbumRating, FormatNumber(ListMath(FieldQuery(Artist - Album /(Year/), [Artist - Album (Year)], RatingOr1, 1, 1),3),1))

Then run ZStats once to calculate the field once for all files. You can re-run it periodically to recalculate - maybe create a Scheduled Task to run it every night or once a week/month, depending on your needs.

Other settings for ZStats.ini (also set your MCWS user/pass there):
Code: [Select]
MCFilter=[Media Type]=[Audio]           # filter to limit processing to a given set of files
UpdateStats=0                           # 1 to update stats as defined in [Stats] sections, 0 to disable
UpdatePlaylists=0                       # 1 to enable playlist processing, 0 to disable
RunExpressions=1                        # 1 to execute [RunBefore] and [RunAfter] expression, 0 to disable
CreateFields=0
Logged

zeltak

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

thx so much

sadly i dont have access to a windows machine thesedays (when i wrote the post i was using jriver 31 on a windows mahcine)

so i understand there is no internal way to do so? maybe ill spin a VM...

thx again

Z
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2030

You can also use global variables which are much snappier than fieldqueries. There is a really old discussion about that somewhere here in the forum
Logged

zeltak

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

thx!

i did a search for "global variables album rating" but got this "Your search query didn't return any matches"

any chance you remember the thread topic?

thx so much

Z
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2530

I've just compiled ZStats for Linux and OSX. Can you please give it a try, even just to confirm if it runs?
https://github.com/zybexXL/MCStats/releases/tag/v1.2.0

This requires Net8 Runtime to be installed. Let me know if you need an ARM64 version.
Logged
Pages: [1]   Go Up