yours-truly-phil / SOULHub

Serves SOUL (Sound Language) Patches
MIT License
7 stars 0 forks source link

Sorting in SOULPatchesGrid by average rating stars #46

Closed yours-truly-phil closed 4 years ago

yours-truly-phil commented 4 years ago

the grid supplies the current page, the number of entries, the column to sort by and the direction (asc / desc) and a class with possible filters to the backend.

what doesn't work is sorting by average rating. The query should be something like select sp from SOULPatch sp left join sp.ratings r where [some filters here] group by sp order by avg(r.stars) desc

I think it might be best to use the criteria builder to dynamically put that query together, but, well, don't know how tbh. so that's that.

yours-truly-phil commented 4 years ago

left join soulpatch to ratings and ordering by the coalesce join value gives the correct result edfe30c06d1a456dce04e6124e7203f25cd99f0c 2dd7ff70858a6e6001de5a3a740097ff3efb1950

what's left to do is, put the predicates for filtering by name or author from the SOULPatchesFetchFilter object into the criteria query and then generalize the criteria query so it works for sorting by all soulpatch attributes. name: alphabetically description: maybe by length, maybe alphabetically, blanks last author: by username alphabetically downloads (no_views): by number ratings: by average rating spfiles: maybe by number of files or no sorting at all

yours-truly-phil commented 4 years ago

b09eb61479d9668dcf4b54c0e5a7d99cbccc29b0