Hi, I am having trouble with sorting and was wondering if anyone can help. I have albums as entities & tracks within albums as field collections. I have fivestar enabled on both and it works perfectly:
Album 1: 8.5/10 (Track A: 3.5/10, Track B: 4.5/10)
Album 2: 9.5/10 (Track C: 5.5/10, Track D: 6.5/10)
I was able to successfully create a view titled "Top rated albums" using a relationship ("Content: Vote results") & sort criteria ("(Vote results) Vote results: Value (desc)"):
Album 2: 9.5/10
Album 1: 8.5/10
But when I try to create a view titled "Top rated tracks" using relationships ("Field collection item: Entity with the Track Listing (field_collection)" & "(field_collection) Content: Vote results") & sort criteria ("(Vote results) Vote results: Value (desc)"), it sorts based on top rated albums instead of tracks no matter what I do:
Track C: 5.5/10 (Album 2: 9.5/10) -> Should be Track D: 6.5/10
Track D: 6.5/10 (Album 2: 9.5/10) -> Should be Track C: 5.5/10
Track A: 3.5/10 (Album 1: 8.5/10) -> Should be Track B: 4.5/10
Track B: 4.5/10 (Album 1: 8.5/10) -> Should be Track A: 3.5/10
The value type ("Percent"), vote tag ("vote") & aggregate function ("Average vote") are of course set correctly, just like the successful view for albums. Am I missing something here?
Comments
Comment #1
druroot commentedDid you set your sort criteria to utilize the proper relationship? It looks like you've got multiple relationships here and you do have to specify within your sort criteria settings which one to use.
Comment #2
jay.lee.bio commentedI just looked, and the dropdown menu under "Relationship" only lets me choose one (which I do think is odd).
Comment #3
jay.lee.bio commentedOk so I changed the sort criteria to "Field collection item: Track Rating (field_trackrating:rating)" (there's also "Field collection item: Track Rating (field_trackrating:target)", but it doesn't do anything), and got the above working and was excited. But after more dummy data entry, it still doesn't work. :-(
Comment #4
jay.lee.bio commentedhttp://drupal.org/node/1809122
Andrew, according to torotil, Voting API is able to handle all entities as "things to be voted on". What's actually voted on depends on the Fivestar module in this case.
I guess what he means is that it's actually Fivestar that doesn't provide a generic entity_vote_results relationship. Therefore it can only do aggregate functions of vote results attached to nodes but not with generic entities like field collections.
So can someone please provide a patch to support this? I'm not good enough with Drupal to do this myself, but will be happy to test it out and make sure it works properly.
Comment #5
frank ralf commentedSee #1823924: Automatic relationships for all entity types for a patch which tackles this problem. Please review that patch over there. TIA