mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Update Slowvote voting methods to use sensible string constants
Summary: Ref T13682. Use API-friendly string constants instead of opaque integers in Slowvote voting methods. Test Plan: Created, edited, and voted in polls with various voting methods. Examined database after migrations. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13682 Differential Revision: https://secure.phabricator.com/D21846
This commit is contained in:
parent
9dad49472c
commit
03d3d1889d
6 changed files with 16 additions and 5 deletions
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll
|
||||
CHANGE method method VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
|
|
@ -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';
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ final class PhabricatorSlowvoteEditController
|
|||
$v_space = $request->getStr('spacePHID');
|
||||
|
||||
if ($is_new) {
|
||||
$poll->setMethod($request->getInt('method'));
|
||||
$poll->setMethod($request->getStr('method'));
|
||||
}
|
||||
|
||||
if (!strlen($v_question)) {
|
||||
|
|
|
@ -54,7 +54,7 @@ final class PhabricatorSlowvotePoll
|
|||
'question' => 'text255',
|
||||
'responseVisibility' => 'text32',
|
||||
'shuffle' => 'bool',
|
||||
'method' => 'uint32',
|
||||
'method' => 'text32',
|
||||
'description' => 'text',
|
||||
'isClosed' => 'bool',
|
||||
),
|
||||
|
|
|
@ -301,13 +301,17 @@ final class SlowvoteEmbedView extends AphrontView {
|
|||
|
||||
$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(
|
||||
|
|
Loading…
Reference in a new issue