Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15391357
D21846.id52067.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D21846.id52067.diff
View Options
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(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 9:29 AM (1 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7651979
Default Alt Text
D21846.id52067.diff (3 KB)
Attached To
Mode
D21846: Update Slowvote voting methods to use sensible string constants
Attached
Detach File
Event Timeline
Log In to Comment