diff --git a/resources/sql/autopatches/20150808.ponder.vote.1.sql b/resources/sql/autopatches/20150808.ponder.vote.1.sql new file mode 100644 index 0000000000..31ac0f8e96 --- /dev/null +++ b/resources/sql/autopatches/20150808.ponder.vote.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_ponder.ponder_question + DROP COLUMN heat; diff --git a/resources/sql/autopatches/20150808.ponder.vote.2.sql b/resources/sql/autopatches/20150808.ponder.vote.2.sql new file mode 100644 index 0000000000..d31e72885d --- /dev/null +++ b/resources/sql/autopatches/20150808.ponder.vote.2.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_ponder.ponder_question + DROP COLUMN voteCount; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 36675ef9f5..c3a7d893b7 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3409,7 +3409,6 @@ phutil_register_library_map(array( 'PonderQuestionCommentController' => 'applications/ponder/controller/PonderQuestionCommentController.php', 'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php', 'PonderQuestionEditor' => 'applications/ponder/editor/PonderQuestionEditor.php', - 'PonderQuestionHasVotingUserEdgeType' => 'applications/ponder/edge/PonderQuestionHasVotingUserEdgeType.php', 'PonderQuestionHistoryController' => 'applications/ponder/controller/PonderQuestionHistoryController.php', 'PonderQuestionListController' => 'applications/ponder/controller/PonderQuestionListController.php', 'PonderQuestionMailReceiver' => 'applications/ponder/mail/PonderQuestionMailReceiver.php', @@ -3432,7 +3431,6 @@ phutil_register_library_map(array( 'PonderVoteEditor' => 'applications/ponder/editor/PonderVoteEditor.php', 'PonderVoteSaveController' => 'applications/ponder/controller/PonderVoteSaveController.php', 'PonderVotingUserHasAnswerEdgeType' => 'applications/ponder/edge/PonderVotingUserHasAnswerEdgeType.php', - 'PonderVotingUserHasQuestionEdgeType' => 'applications/ponder/edge/PonderVotingUserHasQuestionEdgeType.php', 'ProjectAddProjectsEmailCommand' => 'applications/project/command/ProjectAddProjectsEmailCommand.php', 'ProjectBoardTaskCard' => 'applications/project/view/ProjectBoardTaskCard.php', 'ProjectCanLockProjectsCapability' => 'applications/project/capability/ProjectCanLockProjectsCapability.php', @@ -7597,7 +7595,6 @@ phutil_register_library_map(array( 'PonderDAO', 'PhabricatorApplicationTransactionInterface', 'PhabricatorMarkupInterface', - 'PonderVotableInterface', 'PhabricatorSubscribableInterface', 'PhabricatorFlaggableInterface', 'PhabricatorPolicyInterface', @@ -7609,7 +7606,6 @@ phutil_register_library_map(array( 'PonderQuestionCommentController' => 'PonderController', 'PonderQuestionEditController' => 'PonderController', 'PonderQuestionEditor' => 'PonderEditor', - 'PonderQuestionHasVotingUserEdgeType' => 'PhabricatorEdgeType', 'PonderQuestionHistoryController' => 'PonderController', 'PonderQuestionListController' => 'PonderController', 'PonderQuestionMailReceiver' => 'PhabricatorObjectMailReceiver', @@ -7631,7 +7627,6 @@ phutil_register_library_map(array( 'PonderVoteEditor' => 'PhabricatorEditor', 'PonderVoteSaveController' => 'PonderController', 'PonderVotingUserHasAnswerEdgeType' => 'PhabricatorEdgeType', - 'PonderVotingUserHasQuestionEdgeType' => 'PhabricatorEdgeType', 'ProjectAddProjectsEmailCommand' => 'MetaMTAEmailTransactionCommand', 'ProjectBoardTaskCard' => 'Phobject', 'ProjectCanLockProjectsCapability' => 'PhabricatorPolicyCapability', diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php index cad39b4135..30c56a0cc4 100644 --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -10,14 +10,11 @@ final class PonderQuestionViewController extends PonderController { ->setViewer($viewer) ->withIDs(array($id)) ->needAnswers(true) - ->needViewerVotes(true) ->executeOne(); if (!$question) { return new Aphront404Response(); } - $question->attachVotes($viewer->getPHID()); - $question_xactions = $this->buildQuestionTransactions($question); $answers = $this->buildAnswers($question->getAnswers()); diff --git a/src/applications/ponder/edge/PonderQuestionHasVotingUserEdgeType.php b/src/applications/ponder/edge/PonderQuestionHasVotingUserEdgeType.php deleted file mode 100644 index a035942d24..0000000000 --- a/src/applications/ponder/edge/PonderQuestionHasVotingUserEdgeType.php +++ /dev/null @@ -1,105 +0,0 @@ -ids = $ids; @@ -44,11 +43,6 @@ final class PonderQuestionQuery return $this; } - public function needViewerVotes($need_viewer_votes) { - $this->needViewerVotes = $need_viewer_votes; - return $this; - } - public function needProjectPHIDs($need_projects) { $this->needProjectPHIDs = $need_projects; return $this; @@ -106,10 +100,6 @@ final class PonderQuestionQuery ->setOrderVector(array('-id')) ->withQuestionIDs(mpull($questions, 'getID')); - if ($this->needViewerVotes) { - $aquery->needViewerVotes($this->needViewerVotes); - } - $answers = $aquery->execute(); $answers = mgroup($answers, 'getQuestionID'); @@ -119,26 +109,6 @@ final class PonderQuestionQuery } } - if ($this->needViewerVotes) { - $viewer_phid = $this->getViewer()->getPHID(); - - $etype = PonderQuestionHasVotingUserEdgeType::EDGECONST; - $edges = id(new PhabricatorEdgeQuery()) - ->withSourcePHIDs($phids) - ->withDestinationPHIDs(array($viewer_phid)) - ->withEdgeTypes(array($etype)) - ->needEdgeData(true) - ->execute(); - foreach ($questions as $question) { - $user_edge = idx( - $edges[$question->getPHID()][$etype], - $viewer_phid, - array()); - - $question->attachUserVote($viewer_phid, idx($user_edge, 'data', 0)); - } - } - if ($this->needProjectPHIDs) { $edge_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs($phids) diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php index 14fafcecbf..bc71690387 100644 --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -4,7 +4,6 @@ final class PonderQuestion extends PonderDAO implements PhabricatorApplicationTransactionInterface, PhabricatorMarkupInterface, - PonderVotableInterface, PhabricatorSubscribableInterface, PhabricatorFlaggableInterface, PhabricatorPolicyInterface, @@ -25,13 +24,10 @@ final class PonderQuestion extends PonderDAO protected $viewPolicy; protected $spacePHID; - protected $voteCount; protected $answerCount; - protected $heat; protected $mailKey; private $answers; - private $vote; private $comments; private $projectPHIDs = self::ATTACHABLE; @@ -49,9 +45,7 @@ final class PonderQuestion extends PonderDAO ->setAuthorPHID($actor->getPHID()) ->setViewPolicy($view_policy) ->setStatus(PonderQuestionStatus::STATUS_OPEN) - ->setVoteCount(0) ->setAnswerCount(0) - ->setHeat(0.0) ->setSpacePHID($actor->getDefaultSpacePHID()); } @@ -60,10 +54,8 @@ final class PonderQuestion extends PonderDAO self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'title' => 'text255', - 'voteCount' => 'sint32', 'status' => 'text32', 'content' => 'text', - 'heat' => 'double', 'answerCount' => 'uint32', 'mailKey' => 'bytes20', @@ -80,9 +72,6 @@ final class PonderQuestion extends PonderDAO 'authorPHID' => array( 'columns' => array('authorPHID'), ), - 'heat' => array( - 'columns' => array('heat'), - ), 'status' => array( 'columns' => array('status'), ), @@ -103,49 +92,6 @@ final class PonderQuestion extends PonderDAO return PhabricatorContentSource::newFromSerialized($this->contentSource); } - public function attachVotes($user_phid) { - $qa_phids = mpull($this->answers, 'getPHID') + array($this->getPHID()); - - $edges = id(new PhabricatorEdgeQuery()) - ->withSourcePHIDs(array($user_phid)) - ->withDestinationPHIDs($qa_phids) - ->withEdgeTypes( - array( - PonderVotingUserHasQuestionEdgeType::EDGECONST, - PonderVotingUserHasAnswerEdgeType::EDGECONST, - )) - ->needEdgeData(true) - ->execute(); - - $question_edge = - $edges[$user_phid][PonderVotingUserHasQuestionEdgeType::EDGECONST]; - $answer_edges = - $edges[$user_phid][PonderVotingUserHasAnswerEdgeType::EDGECONST]; - $edges = null; - - $this->setUserVote(idx($question_edge, $this->getPHID())); - foreach ($this->answers as $answer) { - $answer->setUserVote(idx($answer_edges, $answer->getPHID())); - } - } - - public function setUserVote($vote) { - $this->vote = $vote['data']; - if (!$this->vote) { - $this->vote = PonderVote::VOTE_NONE; - } - return $this; - } - - public function attachUserVote($user_phid, $vote) { - $this->vote = $vote; - return $this; - } - - public function getUserVote() { - return $this->vote; - } - public function setComments($comments) { $this->comments = $comments; return $this; @@ -229,15 +175,6 @@ final class PonderQuestion extends PonderDAO return (bool)$this->getID(); } - // votable interface - public function getUserVoteEdgeType() { - return PonderVotingUserHasQuestionEdgeType::EDGECONST; - } - - public function getVotablePHID() { - return $this->getPHID(); - } - public function save() { if (!$this->getMailKey()) { $this->setMailKey(Filesystem::readRandomCharacters(20));