From 271d6605a9f0b23685ad9c62e00a9f1739106312 Mon Sep 17 00:00:00 2001 From: Lauri-Henrik Jalonen Date: Fri, 3 May 2013 15:49:29 -0700 Subject: [PATCH] Countdown revamp Summary: countdown_timer table named to countdown. datepoint and related stuff renamed to epoch. Countdowns now have phids. Various UI items changed from timer to countdown. Test Plan: Did run storage upgrade and added some countdowns. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, AnhNhan Maniphest Tasks: T2624 Differential Revision: https://secure.phabricator.com/D5812 --- .../sql/patches/20130502.countdownrevamp1.sql | 8 ++++++ .../sql/patches/20130502.countdownrevamp2.php | 23 +++++++++++++++ .../sql/patches/20130502.countdownrevamp3.sql | 2 ++ src/__celerity_resource_map__.php | 2 +- src/__phutil_library_map__.php | 5 ++-- .../PhabricatorCountdownController.php | 6 ++-- .../PhabricatorCountdownDeleteController.php | 2 +- .../PhabricatorCountdownEditController.php | 28 +++++++++---------- .../PhabricatorCountdownListController.php | 8 +++--- .../PhabricatorCountdownViewController.php | 6 ++-- .../PhabricatorCountdownRemarkupRule.php | 6 ++-- .../storage/PhabricatorCountdown.php | 21 ++++++++++++++ .../countdown/storage/PhabricatorTimer.php | 10 ------- .../patch/PhabricatorBuiltinPatchList.php | 12 ++++++++ 14 files changed, 98 insertions(+), 41 deletions(-) create mode 100644 resources/sql/patches/20130502.countdownrevamp1.sql create mode 100644 resources/sql/patches/20130502.countdownrevamp2.php create mode 100644 resources/sql/patches/20130502.countdownrevamp3.sql create mode 100644 src/applications/countdown/storage/PhabricatorCountdown.php delete mode 100644 src/applications/countdown/storage/PhabricatorTimer.php diff --git a/resources/sql/patches/20130502.countdownrevamp1.sql b/resources/sql/patches/20130502.countdownrevamp1.sql new file mode 100644 index 0000000000..acc3a38f3d --- /dev/null +++ b/resources/sql/patches/20130502.countdownrevamp1.sql @@ -0,0 +1,8 @@ +ALTER TABLE {$NAMESPACE}_countdown.countdown_timer + RENAME TO {$NAMESPACE}_countdown.countdown; + +ALTER TABLE {$NAMESPACE}_countdown.countdown + change datepoint epoch INT UNSIGNED NOT NULL; + +ALTER TABLE {$NAMESPACE}_countdown.countdown + ADD COLUMN phid VARCHAR(64) NOT NULL COLLATE utf8_bin AFTER id; diff --git a/resources/sql/patches/20130502.countdownrevamp2.php b/resources/sql/patches/20130502.countdownrevamp2.php new file mode 100644 index 0000000000..f4fc96413d --- /dev/null +++ b/resources/sql/patches/20130502.countdownrevamp2.php @@ -0,0 +1,23 @@ +openTransaction(); + +foreach (new LiskMigrationIterator($table) as $countdown) { + if ($countdown->getPHID()) { + continue; + } + + echo "."; + + queryfx( + $countdown->establishConnection('w'), + 'UPDATE %T SET phid = %s WHERE id = %d', + $countdown->getTableName(), + $countdown->generatePHID(), + $countdown->getID()); +} + +$table->saveTransaction(); +echo "\nDone.\n"; diff --git a/resources/sql/patches/20130502.countdownrevamp3.sql b/resources/sql/patches/20130502.countdownrevamp3.sql new file mode 100644 index 0000000000..8660025a46 --- /dev/null +++ b/resources/sql/patches/20130502.countdownrevamp3.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_countdown.countdown + ADD UNIQUE KEY `key_phid` (phid); diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index e0e56f29de..46934289e9 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -2271,7 +2271,7 @@ celerity_register_resource_map(array( ), 'javelin-behavior-slowvote-embed' => array( - 'uri' => '/res/1315b118/rsrc/js/application/slowvote/behavior-slowvote-embed.js', + 'uri' => '/res/eef0818f/rsrc/js/application/slowvote/behavior-slowvote-embed.js', 'type' => 'js', 'requires' => array( diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 7b124be28a..e05a1f087e 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -867,6 +867,7 @@ phutil_register_library_map(array( 'PhabricatorContentSourceView' => 'applications/metamta/contentsource/PhabricatorContentSourceView.php', 'PhabricatorController' => 'applications/base/controller/PhabricatorController.php', 'PhabricatorCoreConfigOptions' => 'applications/config/option/PhabricatorCoreConfigOptions.php', + 'PhabricatorCountdown' => 'applications/countdown/storage/PhabricatorCountdown.php', 'PhabricatorCountdownController' => 'applications/countdown/controller/PhabricatorCountdownController.php', 'PhabricatorCountdownDAO' => 'applications/countdown/storage/PhabricatorCountdownDAO.php', 'PhabricatorCountdownDeleteController' => 'applications/countdown/controller/PhabricatorCountdownDeleteController.php', @@ -1427,7 +1428,6 @@ phutil_register_library_map(array( 'PhabricatorTimelineExample' => 'applications/uiexample/examples/PhabricatorTimelineExample.php', 'PhabricatorTimelineIterator' => 'infrastructure/daemon/timeline/cursor/PhabricatorTimelineIterator.php', 'PhabricatorTimelineView' => 'view/layout/PhabricatorTimelineView.php', - 'PhabricatorTimer' => 'applications/countdown/storage/PhabricatorTimer.php', 'PhabricatorToken' => 'applications/tokens/storage/PhabricatorToken.php', 'PhabricatorTokenController' => 'applications/tokens/controller/PhabricatorTokenController.php', 'PhabricatorTokenCount' => 'applications/tokens/storage/PhabricatorTokenCount.php', @@ -2352,6 +2352,7 @@ phutil_register_library_map(array( 'ManiphestSavedQueryListController' => 'ManiphestController', 'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'ManiphestSubpriorityController' => 'ManiphestController', + 'ManiphestSubscribeController' => 'ManiphestController', 'ManiphestTask' => array( 0 => 'ManiphestDAO', @@ -2603,6 +2604,7 @@ phutil_register_library_map(array( 'PhabricatorContentSourceView' => 'AphrontView', 'PhabricatorController' => 'AphrontController', 'PhabricatorCoreConfigOptions' => 'PhabricatorApplicationConfigOptions', + 'PhabricatorCountdown' => 'PhabricatorCountdownDAO', 'PhabricatorCountdownController' => 'PhabricatorController', 'PhabricatorCountdownDAO' => 'PhabricatorLiskDAO', 'PhabricatorCountdownDeleteController' => 'PhabricatorCountdownController', @@ -3121,7 +3123,6 @@ phutil_register_library_map(array( 'PhabricatorTimelineExample' => 'PhabricatorUIExample', 'PhabricatorTimelineIterator' => 'Iterator', 'PhabricatorTimelineView' => 'AphrontView', - 'PhabricatorTimer' => 'PhabricatorCountdownDAO', 'PhabricatorToken' => array( 0 => 'PhabricatorTokenDAO', diff --git a/src/applications/countdown/controller/PhabricatorCountdownController.php b/src/applications/countdown/controller/PhabricatorCountdownController.php index 459d601575..00553299e1 100644 --- a/src/applications/countdown/controller/PhabricatorCountdownController.php +++ b/src/applications/countdown/controller/PhabricatorCountdownController.php @@ -8,9 +8,9 @@ abstract class PhabricatorCountdownController extends PhabricatorController { $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); - $nav->addFilter('', pht('All Timers'), + $nav->addFilter('', pht('All Countdowns'), $this->getApplicationURI('')); - $nav->addFilter('', pht('Create Timer'), + $nav->addFilter('', pht('Create Countdown'), $this->getApplicationURI('edit/')); return $nav; @@ -25,7 +25,7 @@ abstract class PhabricatorCountdownController extends PhabricatorController { $crumbs->addAction( id(new PhabricatorMenuItemView()) - ->setName(pht('Create Timer')) + ->setName(pht('Create Countdown')) ->setHref($this->getApplicationURI('edit/')) ->setIcon('create')); diff --git a/src/applications/countdown/controller/PhabricatorCountdownDeleteController.php b/src/applications/countdown/controller/PhabricatorCountdownDeleteController.php index 800822dda4..95f7f4f953 100644 --- a/src/applications/countdown/controller/PhabricatorCountdownDeleteController.php +++ b/src/applications/countdown/controller/PhabricatorCountdownDeleteController.php @@ -14,7 +14,7 @@ final class PhabricatorCountdownDeleteController $request = $this->getRequest(); $user = $request->getUser(); - $timer = id(new PhabricatorTimer())->load($this->id); + $timer = id(new PhabricatorCountdown())->load($this->id); if (!$timer) { return new Aphront404Response(); } diff --git a/src/applications/countdown/controller/PhabricatorCountdownEditController.php b/src/applications/countdown/controller/PhabricatorCountdownEditController.php index 64c4a9bd7e..452f34e3ab 100644 --- a/src/applications/countdown/controller/PhabricatorCountdownEditController.php +++ b/src/applications/countdown/controller/PhabricatorCountdownEditController.php @@ -12,10 +12,10 @@ final class PhabricatorCountdownEditController $request = $this->getRequest(); $user = $request->getUser(); - $action_label = pht('Create Timer'); + $action_label = pht('Create Countdown'); if ($this->id) { - $timer = id(new PhabricatorTimer())->load($this->id); + $timer = id(new PhabricatorCountdown())->load($this->id); // If no timer is found if (!$timer) { return new Aphront404Response(); @@ -26,10 +26,10 @@ final class PhabricatorCountdownEditController return new Aphront403Response(); } - $action_label = pht('Update Timer'); + $action_label = pht('Update Countdown'); } else { - $timer = new PhabricatorTimer(); - $timer->setDatePoint(time()); + $timer = new PhabricatorCountdown(); + $timer->setEpoch(time()); } $error_view = null; @@ -38,7 +38,7 @@ final class PhabricatorCountdownEditController if ($request->isFormPost()) { $errors = array(); $title = $request->getStr('title'); - $datepoint = $request->getStr('datepoint'); + $epoch = $request->getStr('epoch'); $e_text = null; if (!strlen($title)) { @@ -51,7 +51,7 @@ final class PhabricatorCountdownEditController $timezone = new DateTimeZone($user->getTimezoneIdentifier()); try { - $date = new DateTime($datepoint, $timezone); + $date = new DateTime($epoch, $timezone); $timestamp = $date->format('U'); } catch (Exception $e) { $errors[] = pht('You entered an incorrect date. You can enter date'. @@ -61,7 +61,7 @@ final class PhabricatorCountdownEditController } $timer->setTitle($title); - $timer->setDatePoint($timestamp); + $timer->setEpoch($timestamp); if (!count($errors)) { $timer->setAuthorPHID($user->getPHID()); @@ -76,12 +76,12 @@ final class PhabricatorCountdownEditController } } - if ($timer->getDatePoint()) { - $display_datepoint = phabricator_datetime( - $timer->getDatePoint(), + if ($timer->getEpoch()) { + $display_epoch = phabricator_datetime( + $timer->getEpoch(), $user); } else { - $display_datepoint = $request->getStr('datepoint'); + $display_epoch = $request->getStr('epoch'); } $form = id(new AphrontFormView()) @@ -95,8 +95,8 @@ final class PhabricatorCountdownEditController ->appendChild( id(new AphrontFormTextControl()) ->setLabel(pht('End date')) - ->setValue($display_datepoint) - ->setName('datepoint') + ->setValue($display_epoch) + ->setName('epoch') ->setCaption(pht('Examples: '. '2011-12-25 or 3 hours or '. 'June 8 2011, 5 PM.'))) diff --git a/src/applications/countdown/controller/PhabricatorCountdownListController.php b/src/applications/countdown/controller/PhabricatorCountdownListController.php index 4e2f147095..2ead86805e 100644 --- a/src/applications/countdown/controller/PhabricatorCountdownListController.php +++ b/src/applications/countdown/controller/PhabricatorCountdownListController.php @@ -12,7 +12,7 @@ final class PhabricatorCountdownListController $pager->setOffset($request->getInt('page')); $pager->setURI($request->getRequestURI(), 'page'); - $timers = id(new PhabricatorTimer())->loadAllWhere( + $timers = id(new PhabricatorCountdown())->loadAllWhere( '1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); @@ -54,7 +54,7 @@ final class PhabricatorCountdownListController 'href' => '/countdown/'.$timer->getID().'/', ), $timer->getTitle()), - phabricator_datetime($timer->getDatepoint(), $user), + phabricator_datetime($timer->getEpoch(), $user), $edit_button, $delete_button, ); @@ -83,7 +83,7 @@ final class PhabricatorCountdownListController $panel = id(new AphrontPanelView()) ->appendChild($table) - ->setHeader(pht('Timers')) + ->setHeader(pht('Countdowns')) ->setNoBackground() ->appendChild($pager); @@ -91,7 +91,7 @@ final class PhabricatorCountdownListController ->buildApplicationCrumbs() ->addCrumb( id(new PhabricatorCrumbView()) - ->setName(pht('All Timers')) + ->setName(pht('All Countdowns')) ->setHref($this->getApplicationURI())); return $this->buildApplicationPage( diff --git a/src/applications/countdown/controller/PhabricatorCountdownViewController.php b/src/applications/countdown/controller/PhabricatorCountdownViewController.php index a13c643b44..aa04444365 100644 --- a/src/applications/countdown/controller/PhabricatorCountdownViewController.php +++ b/src/applications/countdown/controller/PhabricatorCountdownViewController.php @@ -14,7 +14,7 @@ final class PhabricatorCountdownViewController $request = $this->getRequest(); $user = $request->getUser(); - $timer = id(new PhabricatorTimer())->load($this->id); + $timer = id(new PhabricatorCountdown())->load($this->id); if (!$timer) { return new Aphront404Response(); } @@ -50,7 +50,7 @@ final class PhabricatorCountdownViewController ', $container, $timer->getTitle(), - phabricator_datetime($timer->getDatePoint(), $user), + phabricator_datetime($timer->getEpoch(), $user), pht('Days'), pht('Hours'), pht('Minutes'), @@ -62,7 +62,7 @@ final class PhabricatorCountdownViewController $chrome_link); Javelin::initBehavior('countdown-timer', array( - 'timestamp' => $timer->getDatepoint(), + 'timestamp' => $timer->getEpoch(), 'container' => $container, )); diff --git a/src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php b/src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php index 765225b4cb..cd35e0d358 100644 --- a/src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php +++ b/src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php @@ -15,7 +15,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule { } protected function markupCountdown($matches) { - $countdown = id(new PhabricatorTimer())->load($matches[1]); + $countdown = id(new PhabricatorCountdown())->load($matches[1]); if (!$countdown) { return $matches[0]; } @@ -23,7 +23,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule { $engine = $this->getEngine(); if ($engine->isTextMode()) { - $date = $countdown->getDatepoint(); + $date = $countdown->getEpoch(); $viewer = $engine->getConfig('viewer'); if ($viewer) { $date = phabricator_datetime($date, $viewer); @@ -36,7 +36,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule { $metadata_key = self::KEY_RULE_COUNTDOWN; $metadata = $engine->getTextMetadata($metadata_key, array()); - $metadata[$id] = array($countdown->getDatepoint(), $token); + $metadata[$id] = array($countdown->getEpoch(), $token); $engine->setTextMetadata($metadata_key, $metadata); return $token; diff --git a/src/applications/countdown/storage/PhabricatorCountdown.php b/src/applications/countdown/storage/PhabricatorCountdown.php new file mode 100644 index 0000000000..f6a0e2eecd --- /dev/null +++ b/src/applications/countdown/storage/PhabricatorCountdown.php @@ -0,0 +1,21 @@ + true, + ) + parent::getConfiguration(); + } + + public function generatePHID() { + return PhabricatorPHID::generateNewPHID('CDWN'); + } + +} diff --git a/src/applications/countdown/storage/PhabricatorTimer.php b/src/applications/countdown/storage/PhabricatorTimer.php deleted file mode 100644 index 138f558dac..0000000000 --- a/src/applications/countdown/storage/PhabricatorTimer.php +++ /dev/null @@ -1,10 +0,0 @@ - 'sql', 'name' => $this->getPatchPath('20130426.search_savedquery.sql'), ), + '20130502.countdownrevamp1.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20130502.countdownrevamp1.sql'), + ), + '20130502.countdownrevamp2.php' => array( + 'type' => 'php', + 'name' => $this->getPatchPath('20130502.countdownrevamp2.php'), + ), + '20130502.countdownrevamp3.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20130502.countdownrevamp3.sql'), + ), ); } }