public function actionResetDb() { die; LikeFbPost::model()->deleteAll(); LikeFbFiles::model()->deleteAll(); LikeFbDoc::model()->deleteAll(); LikeFbCommentDoc::model()->deleteAll(); LikeFbCommentFile::model()->deleteAll(); LikeFbCommentPost::model()->deleteAll(); PhotoFbCommentPost::model()->deleteAll(); PhotoFbPost::model()->deleteAll(); FbDocComment::model()->deleteAll(); FbFilesComment::model()->deleteAll(); FbPostComment::model()->deleteAll(); FbPost::model()->deleteAll(); FbFiles::model()->deleteAll(); FbDoc::model()->deleteAll(); MemberDegreeGroup::model()->deleteAll(); MemberExamGroup::model()->deleteAll(); }
echo $n_total_photo_exam_comments; ?> </label> <?php } else { $ref_id = $group->eid; $exam = ExamGroup::model()->findByPk($ref_id); $posts_exam = FbPost::model()->findAllByAttributes(array('exam_group_id' => $ref_id)); $exam_member = MemberExamGroup::model()->findAllByAttributes(array('user_group_id' => $ref_id)); // array_push($total_post_exam, $posts_exam); $docs_exam = FbDoc::model()->findAllByAttributes(array('exam_group_id' => $ref_id)); $files_exam = FbFiles::model()->findAllByAttributes(array('exam_group_id' => $ref_id)); foreach ($posts_exam as $pe) { $posts_exam_like = LikeFbPost::model()->findAllByAttributes(array('ref_entity_id' => $pe->fbpid)); // array_push($total_posts_exam_like, $posts_exam_like); $n_total_post_exam_like += count($posts_exam_like); $photos_exam_post = PhotoFbPost::model()->findAllByAttributes(array('element_id' => $pe->fbpid)); // array_push($total_photo_post_exam, $photos_exam_post); $n_total_photo_post_exam += count($photos_exam_post); $comments = FbPostComment::model()->findAllByAttributes(array('ref_entity_id' => $pe->fbpid)); foreach ($comments as $c) { array_push($total_exam_post_comment, $c); $photo_exam_comments = PhotoFbCommentPost::model()->findAllByAttributes(array('element_id' => $c->cid)); $n_total_photo_exam_comments += count($photo_exam_comments); // array_push($total_photo_exam_comments, $photo_exam_comments); $comment_exam_like = LikeFbCommentPost::model()->findAllByAttributes(array('ref_entity_id' => $c->cid)); $n_total_like_comments += $c->like_count; // array_push($total_like_exam_comments, $comment_exam_like); }
public function featuresRappresentation() { set_time_limit(0); $criteria = new CDbCriteria(); $criteria->condition = " post_type_l1 is null"; $post = FbPost::model()->findAll($criteria); foreach ($post as $p) { $features_rappresentation = new FeaturesRappresentation(); $features_rappresentation->pid = $p->fbpid; $message = strtolower($p->message); $features_rappresentation->format_info = substr_count($message, "\n"); $features_rappresentation->n_char = strlen($message); $comments = FbPostComment::model()->findAllByAttributes(array('ref_entity_id' => $p->fbpid)); $features_rappresentation->n_comment = count($comments); $comment_char_lenght = 0; $n_like_comment = 0; $top_author_comment = "false"; foreach ($comments as $c) { $comment_char_lenght += strlen($c->message); $n_like_comment += $c->like_count; $author_comment = Users::model()->findByPk($c->author_id); if ($author_comment->user_type == "top") { $top_author_comment = "true"; } } $features_rappresentation->comment_author_top = $top_author_comment; $features_rappresentation->n_char_comment_length = $comment_char_lenght; if ($features_rappresentation->comment_author_top != 0 && $features_rappresentation->n_char_comment_length != 0) { $features_rappresentation->n_char_comment_length_ratio = round($comment_char_lenght / $features_rappresentation->n_comment, 4); } else { $features_rappresentation->n_char_comment_length_ratio = 0; } $features_rappresentation->n_like_comment = $n_like_comment; if ($p->link != null) { $features_rappresentation->link_presence = "true"; } else { $features_rappresentation->link_presence = "false"; } if ($p->application != null) { $features_rappresentation->device = "mobile"; } else { $features_rappresentation->device = "web"; } $photo = PhotoFbPost::model()->findAllByAttributes(array("element_id" => $p->fbpid)); if ($photo != null) { $features_rappresentation->picture_presence = "true"; } else { $features_rappresentation->picture_presence = "false"; } $like = LikeFbPost::model()->findAllByAttributes(array("ref_entity_id" => $p->fbpid)); $features_rappresentation->n_like = count($like); $top_user_like = "false"; foreach ($like as $l) { $author_like = Users::model()->findByPk($l->user_id); if ($author_like->user_type == "top") { $top_user_like = "true"; break; } } $features_rappresentation->like_top_user = $top_user_like; $top_author = "false"; $author_post = Users::model()->findByPk($p->author_id); if ($author_post->user_type == "top") { $features_rappresentation->top_author_user = "******"; } else { $features_rappresentation->top_author_user = "******"; } $features_rappresentation->question_mark_presence = substr_count($message, "?"); $features_rappresentation->math_symbols_presence = $this->checkMathSymbol($message); $features_rappresentation->time_element_presence = $this->checkTemporalElement($message); $features_rappresentation->save(); } echo 'OK ;)'; }
public function addLikes($id, $question_id) { $likes = LikeFbPost::model()->findAllByAttributes(array("ref_entity_id" => $id)); foreach ($likes as $l) { $this->addFakeName($l->user_id); $qa_user_id = $this->addAuthor($l->user_id); if (is_array($qa_user_id)) { $qa_user_id = $qa_user_id[0]; } $user = Users::model()->findByPk($l->user_id); $fake_user = FakeUser::model()->findByPk($user->fake_name_id); $post = array("postid" => $question_id, "userid" => $qa_user_id, "basetype" => "Q"); qa_vote_set($post, $qa_user_id, $fake_user->first_name . $fake_user->last_name, null, 1); } }
public function deleteDegreeInfo() { die; $post = FbPost::model()->findAllByAttributes(array('exam_group_id' => '123811091057378')); foreach ($post as $p) { $comment = FbPostComment::model()->deleteAllByAttributes(array('ref_entity_id' => $p->fbpid)); $photo = PhotoFbPost::model()->deleteAllByAttributes(array('element_id' => $p->fbpid)); $like = LikeFbPost::model()->deleteAllByAttributes(array('ref_entity_id' => $p->fbpid)); } $doc = FbDoc::model()->deleteAllByAttributes(array('exam_group_id' => '123811091057378')); $files = FbFiles::model()->deleteAllByAttributes(array('exam_group_id' => '123811091057378')); $post = FbPost::model()->deleteAllByAttributes(array('exam_group_id' => '123811091057378')); $exam_group = ExamGroup::model()->deleteAllByAttributes(array('eid' => '123811091057378')); $connection = Yii::app()->db; $command = $connection->createCommand("SELECT * FROM member_exam_group where user_group_id = '123811091057378' and user_id not in (select user_id from member_exam_group where user_group_id != '123811091057378')and user_id not in (select user_id from qeanalysis.member_degree_group where user_group_id != '123811091057378')"); $row = $command->queryAll(); foreach ($row as $r) { $user_personal_info = UserPersonalInfo::model()->deleteByPk($r['user_id']); echo $r['user_id']; $user = User::model()->deleteByPk($r['user_id']); $member = MemberExamGroup::model()->deleteAllByAttributes(array('user_id' => $r['user_id'], 'user_group_id' => '123811091057378')); } // echo ' post: '. $post . ' user '. $user. ' personal info: '. $user_personal_info. ' '.$member ; }