Start a new topic

Share user-ratings

I think it would be great, when Helium (optionally) shows ratings from other users, if a user does not have rated a track himself.

Two ways I would think of doing this:

1. Select a "master" when creating a new user:
I guess this is the "easy" way, since you would simply clone the master's ratings into the ratings of the new user.
INSERT INTO `tblrating`(`Detail_ID`, `User_ID`, `Rating`) SELECT %new_user_id% AS `Detail_ID`, `User_ID`, `Rating` FROM `tblrating` WHERE User_ID = %master_user_id%

When editing a user, the SQL-query would look like this:

INSERT INTO `tblrating`(`Detail_ID`, `User_ID`, `Rating`) SELECT `Detail_ID`, %edited_user_id% AS `User_ID`, `Rating` FROM `tblrating` WHERE User_ID = %master_user_id% AND `Detail_ID` NOT IN (SELECT `Detail_ID` FROM `tblrating` WHERE `User_ID` = %edited_user_id% AND `Rating` IS NOT NULL)

 

2. Create an "average" rating from existing users:
This might be somewhat harder to do, since I don't know if Helium can handle all values...
INSERT INTO `tblrating`(`Detail_ID`, `User_ID`, `Rating`) SELECT DISTINCT(`Detail_ID`), %new_user_id% AS `User_ID`, AVG(`Rating`) FROM `tblrating` GROUP BY `Detail_ID`

 When editing a user, the SQL-query would look like this:

INSERT INTO `tblrating`(`Detail_ID`, `User_ID`, `Rating`) SELECT DISTINCT(`Detail_ID`), edited_user_id AS `User_ID`, AVG(`Rating`) FROM `tblrating` WHERE `User_ID` != edited_user_id AND `Detail_ID` NOT IN (SELECT `Detail_ID` FROM `tblrating` WHERE `User_ID` = edited_user_id AND `Rating` IS NOT NULL) GROUP BY `Detail_ID`



1 person likes this idea
Login or Signup to post a comment