diff --git a/application/modules/default/models/ProjectTagRatings.php b/application/modules/default/models/ProjectTagRatings.php index 4bdf53968..f6ad2216c 100755 --- a/application/modules/default/models/ProjectTagRatings.php +++ b/application/modules/default/models/ProjectTagRatings.php @@ -1,101 +1,101 @@ . **/ class Default_Model_ProjectTagRatings { /** * @param $project_id */ public function getProjectTagRatings($project_id) { $sql = " SELECT r.tag_id, r.vote, r.member_id, r.tag_rating_id FROM stat_projects p - inner join category_tag_group_rating g on p.project_category_id = g.category_id - inner join tag_group_item i on i.tag_group_id = g.tag_group_id + inner join project_category g on p.project_category_id = g.project_category_id + inner join tag_group_item i on i.tag_group_id = g.tag_rating inner join tag_rating r on r.tag_id = i.tag_id and r.project_id = p.project_id and r.is_deleted=0 inner join tag t on t.tag_id = r.tag_id where p.project_id = :project_id "; $result = Zend_Db_Table::getDefaultAdapter()->query($sql, array('project_id' => $project_id))->fetchAll(); return $result; } public function getCategoryTagRatings($category_id) { $sql ="SELECT - t.tag_id as id, - t.tag_fullname as name, - tg.group_display_name - FROM category_tag_group_rating g - inner join tag_group_item i on i.tag_group_id = g.tag_group_id - inner join tag t on t.tag_id = i.tag_id - inner join tag_group tg on g.tag_group_id = tg.group_id - where g.category_id = :category_id + t.tag_id as id, + t.tag_fullname as name, + tg.group_display_name + FROM project_category g + inner join tag_group_item i on i.tag_group_id = g.tag_rating + inner join tag t on t.tag_id = i.tag_id + inner join tag_group tg on g.tag_rating = tg.group_id + where g.project_category_id =:category_id "; $result = Zend_Db_Table::getDefaultAdapter()->query($sql, array('category_id' => $category_id))->fetchAll(); return $result; } /** * @return tag_rating_id,vote/false */ public function checkIfVote($member_id,$project_id,$tag_id) { $sql = "select tag_rating_id,vote from tag_rating where member_id=:member_id and project_id=:project_id and tag_id=:tag_id and is_deleted=0"; $result = Zend_Db_Table::getDefaultAdapter()->fetchRow($sql,array("member_id"=>$member_id ,"project_id"=>$project_id ,"tag_id" =>$tag_id )); return $result; if($result && $result['tag_rating_id']) { return $result; }else{ return false; } } public function doVote($member_id,$project_id,$tag_id,$vote) { Zend_Db_Table::getDefaultAdapter()->insert('tag_rating' ,array('member_id' => $member_id ,'project_id' => $project_id ,'tag_id' => $tag_id ,'vote' => $vote )); } public function removeVote($tag_rating_id) { $sql ="update tag_rating set is_deleted=1, deleted_at=now() where tag_rating_id=".$tag_rating_id; Zend_Db_Table::getDefaultAdapter()->query($sql); } } \ No newline at end of file diff --git a/sql_code/20191203_tag_rating.sql b/sql_code/20191203_tag_rating.sql index 455ac0d0a..13ad22025 100644 --- a/sql_code/20191203_tag_rating.sql +++ b/sql_code/20191203_tag_rating.sql @@ -1,46 +1,49 @@ INSERT INTO `pling`.`tag_group` (`group_id`, `group_name`, `group_display_name`, `is_multi_select`) VALUES ('34', 'desktop-environments', 'Desktop Environments KDE/GNOME/XFCE...', '0'); INSERT INTO `tag` (`tag_name`, `tag_fullname`, `is_active`) VALUES ('desktop-env-kde', 'KDE Plasma', '1'); INSERT INTO `tag` (`tag_name`, `tag_fullname`, `is_active`) VALUES ('desktop-env-gnome', 'GNOME', '1'); INSERT INTO `tag` (`tag_name`, `tag_fullname`, `is_active`) VALUES ('desktop-env-xfce', 'XFCE', '1'); INSERT INTO `tag` (`tag_name`, `tag_fullname`, `is_active`) VALUES ('desktop-env-cinnamon', 'Cinnamon', '1'); INSERT INTO `tag` (`tag_name`, `tag_fullname`, `is_active`) VALUES ('desktop-env-mate', 'Mate', '1'); INSERT INTO `tag` (`tag_name`, `tag_fullname`, `is_active`) VALUES ('desktop-env-next', 'Next', '1'); INSERT INTO `tag` (`tag_name`, `tag_fullname`, `is_active`) VALUES ('desktop-env-budgie', 'Budgie', '1'); INSERT INTO `tag` (`tag_name`, `tag_fullname`, `is_active`) VALUES ('desktop-env-enlightenment', 'Enlightenment', '1'); insert into tag_group_item(tag_group_id,tag_id) values( 34, 5741); insert into tag_group_item(tag_group_id,tag_id) values( 34, 5742); insert into tag_group_item(tag_group_id,tag_id) values( 34, 5743); insert into tag_group_item(tag_group_id,tag_id) values( 34, 5744); insert into tag_group_item(tag_group_id,tag_id) values( 34, 5745); insert into tag_group_item(tag_group_id,tag_id) values( 34, 5746); insert into tag_group_item(tag_group_id,tag_id) values( 34, 5747); insert into tag_group_item(tag_group_id,tag_id) values( 34, 5748); CREATE TABLE `tag_rating` ( `tag_rating_id` INT(11) NOT NULL AUTO_INCREMENT, `project_id` INT(11) NOT NULL, `member_id` INT(11) NOT NULL, `tag_id` INT(11) NOT NULL, `vote` INT(1) NOT NULL comment '1 = like -1 = dislike 0=neutral', `is_deleted` INT(1) NOT NULL DEFAULT 0, `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP, `deleted_at` TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (`tag_rating_id`) ) ; -CREATE TABLE `category_tag_group_rating` -( - `category_tag_group_rating_id` INT(11) NOT NULL AUTO_INCREMENT, - `category_id` INT(11) NOT NULL, - `tag_group_id` INT(11) NOT NULL, - PRIMARY KEY (`category_tag_group_rating_id`) -) -; \ No newline at end of file +-- CREATE TABLE `category_tag_group_rating` +-- ( +-- `category_tag_group_rating_id` INT(11) NOT NULL AUTO_INCREMENT, +-- `category_id` INT(11) NOT NULL, +-- `tag_group_id` INT(11) NOT NULL, +-- PRIMARY KEY (`category_tag_group_rating_id`) +-- ) +-- ; + +ALTER TABLE `project_category` + ADD COLUMN `tag_rating` INT(11) comment 'tag_group_id' AFTER `browse_list_type`;