Hi. I am using the CB plugin from the JLexReview component to able the user to make reviews and ratings. The new CB plug_cbprofilebook adds the cb_pb_profile_rating to the com_profiler table. That opens the opportunity to me to create a CB List ordered by that field but I need to update this field with the JLexReview data.
With the JLexReview support help this is the needed query:
UPDATE scr_comprofiler c
SET cb_pb_profile_rating =
( SELECT (rating.sum_rate/rating.count_orate) as avgrate
FROM scr_jlexreview r
INNER JOIN scr_users u ON u.id=r.object_id
LEFT JOIN (
SELECT object, object_id, CONCAT(object,'_',object_id) kk,
SUM(CASE WHEN review_rate>0 THEN 1 ELSE 0 END) count_orate,
SUM(review_rate) sum_rate
FROM scr_jlexreview
WHERE review_rate<= 5 AND published=1 AND object='com_comprofiler'
GROUP BY kk ) AS rating ON rating.object_id=r.object_id
WHERE r.published=1 AND rating.count_orate>0 AND c.user_id=r.object_id
GROUP BY r.object_id
ORDER BY avgrate DESC )
WHERE c.approved>0
Then my question:
Where it is best to update the new cb_pb_profile_rating comprofiler table field in order to get an ordered List by this field?. How could I do that?. Any suggestions?.
Thanks in advance.
Octavio.
CB ProfileBook ratings are done when a post is made. So the rating is directly tied to a post. Adding to the rating requires adding a new post. You may want to use the Rating fieldtype included with CB 2.x instead, which calculates its rating based off entries in the _comprofiler_ratings database table where you could insert new ratings directly.
Kyle (Krileon) Community Builder Team Member Before posting on forums:
Read FAQ thoroughly
+
Read our Documentation
+
Search the forums CB links:
Documentation
-
Localization
-
CB Quickstart
-
CB Paid Subscriptions
-
Add-Ons
-
Forge
-- If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
-- If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please
send me a private message
with your thread and will reply when possible!
-- Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
-- My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Well, This _comprofiler_ratings database table has other fields than id, userid, and rating. What about them?. Which values do I need to insert in those fields using an INSERT SQL statement?.
The table already describes what it does. ID is left alone because it's auto increment. See the below column descriptions.
user_id = The user that is rating
type = The location the rating came from (currently only "field" is used)
item = The item associated with the type (currently only the fields id is used)
target = The recipient of the rating (user id)
rating = The rating the user selected (e.g. 1 is 1 star, 2 is 2 stars, etc..)
ip_address = Simply for logging purposes (doesn't have to be used)
date = The datetime the rating was made
Kyle (Krileon) Community Builder Team Member Before posting on forums:
Read FAQ thoroughly
+
Read our Documentation
+
Search the forums CB links:
Documentation
-
Localization
-
CB Quickstart
-
CB Paid Subscriptions
-
Add-Ons
-
Forge
-- If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
-- If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please
send me a private message
with your thread and will reply when possible!
-- Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
-- My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.