INTERACT FORUM

Please login or register.

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

Author Topic: Help with code for "top albums"  (Read 1042 times)

exodus1977

  • Recent member
  • *
  • Posts: 25
Help with code for "top albums"
« on: September 23, 2011, 12:18:43 am »

I'd like to make a smartlist based on custom code to list my "top rated albums."  I'm thinking this will be a list of albums ranked by the average rating score of all the single tracks within them (and perhaps weight that score by the number of plays, but that's for later).

Anyway, a good starting point would be to have an expression that returns the average [rating] for an album.  In a simplistic sense, this should be: (sum of all star ratings given for all tracks contained in album) / (total number of tracks in that album) = (average star rating)

Could anyone help me come up with an expression for this?  Thanks.
Logged

rick.ca

  • Citizen of the Universe
  • *****
  • Posts: 3729
Re: Help with code for "top albums"
« Reply #1 on: September 23, 2011, 01:06:39 am »

The expression language operates only on values from individual files. There's no way to compute something like an average of values from a set of files.

The only workaround I can think of would be to manually set and periodically update album ratings. Create an album-relational field (say [a.Rating]) to record an album rating. Use or create a Categories View displaying [Album] as the category (i.e., in the top pane) in a Details list style. Add [Rating] to the view. This will list all albums, showing the average value of [Rating] for each. Sort this by [Rating], and use that to select all albums for which you would like to set a particular [a.Rating] value. If you need a more precise value than whole stars, use an expression column to display [Rating]—that will show the actual numerical average. When creating [a.Rating], you may prefer to make it a decimal type, rather than an integer/star field.

This seems cumbersome, but it would only take a few minutes to set appropriate [a.Rating] values for your entire collection. The same thing could be done with [Number Plays] (i.e., create an album-relational field [a.Plays]), and the two combined in some fashion using an expression.
Logged
Pages: [1]   Go Up