JrCore_list order with multiple facters

MySong
MySong
@mysong
10 years ago
155 posts
Trying to list item order using multiple factors. For example by rating and then by total count, so an object that was rated 5 four times will be listed before an object rated 5 only one time.

Using above example understand that I would have to use the following two fields...

First
audio_rating_1_average_count numerical_desc
Then
audio_rating_overall_count numerical_desc

but not sure proper way to add it into the code. Checked https://www.jamroom.net/the-jamroom-network/documentation/development/89/jrcore-list and tried a number of experiments but could not get it to work. Also tried using... but could not get it to work.

order_by1="audio_rating_overall_average numerical_desc" order_by2="audio_rating_overall_count numerical_desc"


There are also a variations in the code throughout the skin templates where list orders would have to be applied, would be good if knew how to apply it in all cases.

Here are the various code setups where this would apply.

Setup 1 - {$order_by = "audio_rating_1_average_count NUMERICAL_DESC"}

Setup 2 - {jrCore_list module="jrAudio" order_by="audio_rating_overall_average_count numerical_desc" quota_id=$_conf.AzamraNew_artist_quota search1="profile_active = 1" template="index_top_singles_rating_row.tpl" require_image="audio_image" pagebreak="6" page=$_post.p}

Setup 3 - {assign var="order_by" value="audio_rating_1_average_count NUMERICAL_DESC"}

Thanks
updated by @mysong: 09/13/14 02:39:20AM
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
Your "Setup 1" is smarty shorthand for assign, so Setup 1 and Setup 3 are the same - they both assign a string to a variable. They would both then use that variable in jrCore_list as order_by=$order_by, so there is no real difference between all 3 setups.

Looks like your code is ok, but you aren't understanding what the code does or what ratings are. audio_rating_overall_average can be 4.33.

Your audio will be listed by the rating (specifically rating_1, but there can be many), and then by the number of times the item has been rated (for all ratings for the item if there are many).

If you really want to list all items with a 4 star rating and then order those by the number of times they were rated 4 stars you are going to have a lot of work to do. But bear in mind that you won't end up with useful results - something which has a 4 star rating might have zero actual 4 star ratings but plenty of 3 star ratings and plenty of 5 star ratings. And something with 10 rates and an average rating of 4.33 with one 5 star rating will still list above something with an average of 4.32 and 10000 5 star rates.

If you really do want to do that, you can access the number of 5 star ratings using audio_rating_1_5

It would be sensible to spend some time looking at the database using phpmyadmin to see what is recorded when an item is rated and get to understanding of how ratings work.

This would list by rating, and then order by the number of 5 star ratings
order_by1="audio_rating_overall_average numerical_desc"
order_by2="audio_rating_1_5 numerical_desc"
BUT, as said above, audio_rating_overall_average can be 4.33, and the second order_by will only apply when items have the same audio_rating_overall_average...


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
MySong
MySong
@mysong
10 years ago
155 posts
Thanks for pointing that out, you are correct, goal would be to order by
1) Average rating
2) Total amount of times rated (not by a specific number)

Did not realize there were decimals. So I guess a song rated 5 one time will outrank a song rated 100 times with an average of 4.95.

Realize that adding 'audio_rating_overall_count numerical_desc' as a second factor will not help much but can in some cases where average is exactly the same.

Can anyone provide an example how to properly place the two order factors (audio_rating_1_average_count numerical_desc and audio_rating_overall_count numerical_desc) into the 3 snips of code listed above.

Thanks
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
There is no possible way to place them in the 3 snips of code.

1 and 3 assign to a single variable.

You need to find each jrCore_list function that they are providing $order_by to, and change them to use order_by1 and order_by2


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 07/27/14 03:29:29PM
MySong
MySong
@mysong
10 years ago
155 posts
Think I will just use "audio_file_stream_count numerical_desc" for now on 'top lists'.

Since if audio_rating_1_average_count numerical_desc is used, as soon as a song is rated 5 once it would jump to the top, ranking over commonly rated songs that have a 4.99 or lower average.

If audio_rating_1_5 is used; it helps towards the top of the list but in the end a song with an average of 1 that had even one 5 star vote will be above a song with an average of 4 that had not 5 ratings.
paul
@paul
10 years ago
4,331 posts
A custom module could listen for jrRating calls and add in a 'weighted' rating value based on a pre-defined rule using total number of ratings and their values.
Just a thought :-)


--
Paul Asher - JR Developer and System Import Specialist
MySong
MySong
@mysong
10 years ago
155 posts
If you guys ever create it, big chance we will buy it :)
brian
@brian
10 years ago
10,148 posts
I actually have this on a todo list from earlier discussions about this - the rating module can easily do this, it's just not something done yet.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
MySong
MySong
@mysong
10 years ago
155 posts
Originally did not take decimal rating into account so it could have been resolved with a 2nd order factor like 'overall_count' but now realize that even one -5 rating will make an item fall below a fresh one time rated 5 item.
MySong
MySong
@mysong
10 years ago
155 posts
Just another suggestion for the rating module...

Currently if an item has never been rated it will not show up on any rating based lists (since no rating data in datastore for item). It would be good if unrated items were given a value of 0, so at least they would show up all the way at the end of the lists.
paul
@paul
10 years ago
4,331 posts
Unfortunately the way that DataStores work make this not possible because, as you say, if a field doesn't exist for a DS item, the item cannot be listed by that field.
A way around this would be a custom module that 'listened' for new DS items being created and added in the rating fields, preset to zero. Fairly simple to do!!


--
Paul Asher - JR Developer and System Import Specialist
brian
@brian
10 years ago
10,148 posts
paul:
Unfortunately the way that DataStores work make this not possible because, as you say, if a field doesn't exist for a DS item, the item cannot be listed by that field.
A way around this would be a custom module that 'listened' for new DS items being created and added in the rating fields, preset to zero. Fairly simple to do!!

I don't think we'd want to do it this way. A better way is to have a subquery that gets all the items that are MISSING the key, then places those as an OR IN clause on the main query. Doable, but could be a bit of a performance hitter.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
10 years ago
10,148 posts
I'll be working on the ratings module fairly soon here and will have a new order_by - i.e. something like:

order_by="bayesian_rating"

that will handle all this.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
paul
@paul
10 years ago
4,331 posts
You know, I now remember us talking about this a few months ago.
For MySong's (and my) benefits, what was the sub-query we need to put as the jrCore_list search parameter to do this?


--
Paul Asher - JR Developer and System Import Specialist
brian
@brian
10 years ago
10,148 posts
paul:
You know, I now remember us talking about this a few months ago.
For MySong's (and my) benefits, what was the sub-query we need to put as the jrCore_list search parameter to do this?

It's not something you can put directly into a jrCore_list call - it needs to be setup as a db_search_params listener for the jrRating module. That listener will then:

- look for the special "order_by" param being passed in and if it finds it:
- run a query to get all ratings and counts and figure out the correct order for the items
- rewrite the order_by to use the new order

The subquery would come in step 2 - basically it would combine 2 result sets - the first being the the items as ordered by ratings (those with ratings) and the second set being unrated items.

So I need to play with that a bit and make sure it can do all that and remain performant.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
10 years ago
10,148 posts
OK the latest ratings module now has support for a special "order_by" parameter - i.e.

order_by="bayesian_rating desc"

This will order the ratings based on a special "weighted" Bayesian method that will take several factors into account when doing the ranking, so it should rank items with a lot of votes higher than a highly rated item with a single vote - basically it will even things out.

Check it out and let me know how it works for you.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 08/09/14 06:27:30AM
MySong
MySong
@mysong
10 years ago
155 posts
Thanks @brian

Added "bayesian_rating numerical_desc" to 'Top Singles' on home page, looks good. Will add in a few more places as well.
brian
@brian
10 years ago
10,148 posts
MySong:
Thanks @brian

Added "bayesian_rating numerical_desc" to 'Top Singles' on home page, looks good. Will add in a few more places as well.

Glad to hear it - thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net