diff --git a/resources/sql/autopatches/20220525.slowvote.06.method-type.sql b/resources/sql/autopatches/20220525.slowvote.06.method-type.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20220525.slowvote.06.method-type.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll + CHANGE method method VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT}; diff --git a/resources/sql/autopatches/20220525.slowvote.07.method-value.sql b/resources/sql/autopatches/20220525.slowvote.07.method-value.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20220525.slowvote.07.method-value.sql @@ -0,0 +1,5 @@ +UPDATE {$NAMESPACE}_slowvote.slowvote_poll + SET method = 'plurality' WHERE method = '0'; + +UPDATE {$NAMESPACE}_slowvote.slowvote_poll + SET method = 'approval' WHERE method = '1'; diff --git a/src/applications/slowvote/constants/SlowvotePollVotingMethod.php b/src/applications/slowvote/constants/SlowvotePollVotingMethod.php --- a/src/applications/slowvote/constants/SlowvotePollVotingMethod.php +++ b/src/applications/slowvote/constants/SlowvotePollVotingMethod.php @@ -3,8 +3,8 @@ final class SlowvotePollVotingMethod extends Phobject { - const METHOD_PLURALITY = 0; - const METHOD_APPROVAL = 1; + const METHOD_PLURALITY = 'plurality'; + const METHOD_APPROVAL = 'approval'; private $key; diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php --- a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php @@ -57,7 +57,7 @@ $v_space = $request->getStr('spacePHID'); if ($is_new) { - $poll->setMethod($request->getInt('method')); + $poll->setMethod($request->getStr('method')); } if (!strlen($v_question)) { diff --git a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php --- a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php +++ b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php @@ -54,7 +54,7 @@ 'question' => 'text255', 'responseVisibility' => 'text32', 'shuffle' => 'bool', - 'method' => 'uint32', + 'method' => 'text32', 'description' => 'text', 'isClosed' => 'bool', ), diff --git a/src/applications/slowvote/view/SlowvoteEmbedView.php b/src/applications/slowvote/view/SlowvoteEmbedView.php --- a/src/applications/slowvote/view/SlowvoteEmbedView.php +++ b/src/applications/slowvote/view/SlowvoteEmbedView.php @@ -301,13 +301,17 @@ $percent = sprintf('%d%%', $count ? 100 * $choices / $count : 0); - switch ($poll->getMethod()) { + $method = $poll->getMethod(); + switch ($method) { case SlowvotePollVotingMethod::METHOD_PLURALITY: $status = pht('%s (%d / %d)', $percent, $choices, $count); break; case SlowvotePollVotingMethod::METHOD_APPROVAL: $status = pht('%s Approval (%d / %d)', $percent, $choices, $count); break; + default: + $status = pht('Unknown ("%s")', $method); + break; } return phutil_tag(