1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

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
This commit is contained in:
Lauri-Henrik Jalonen 2013-05-03 15:49:29 -07:00 committed by epriestley
parent 1fa307750d
commit 271d6605a9
14 changed files with 98 additions and 41 deletions

View file

@ -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;

View file

@ -0,0 +1,23 @@
<?php
echo "Giving countdowns PHIDs";
$table = new PhabricatorCountdown();
$table->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";

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_countdown.countdown
ADD UNIQUE KEY `key_phid` (phid);

View file

@ -2271,7 +2271,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-slowvote-embed' => 'javelin-behavior-slowvote-embed' =>
array( 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', 'type' => 'js',
'requires' => 'requires' =>
array( array(

View file

@ -867,6 +867,7 @@ phutil_register_library_map(array(
'PhabricatorContentSourceView' => 'applications/metamta/contentsource/PhabricatorContentSourceView.php', 'PhabricatorContentSourceView' => 'applications/metamta/contentsource/PhabricatorContentSourceView.php',
'PhabricatorController' => 'applications/base/controller/PhabricatorController.php', 'PhabricatorController' => 'applications/base/controller/PhabricatorController.php',
'PhabricatorCoreConfigOptions' => 'applications/config/option/PhabricatorCoreConfigOptions.php', 'PhabricatorCoreConfigOptions' => 'applications/config/option/PhabricatorCoreConfigOptions.php',
'PhabricatorCountdown' => 'applications/countdown/storage/PhabricatorCountdown.php',
'PhabricatorCountdownController' => 'applications/countdown/controller/PhabricatorCountdownController.php', 'PhabricatorCountdownController' => 'applications/countdown/controller/PhabricatorCountdownController.php',
'PhabricatorCountdownDAO' => 'applications/countdown/storage/PhabricatorCountdownDAO.php', 'PhabricatorCountdownDAO' => 'applications/countdown/storage/PhabricatorCountdownDAO.php',
'PhabricatorCountdownDeleteController' => 'applications/countdown/controller/PhabricatorCountdownDeleteController.php', 'PhabricatorCountdownDeleteController' => 'applications/countdown/controller/PhabricatorCountdownDeleteController.php',
@ -1427,7 +1428,6 @@ phutil_register_library_map(array(
'PhabricatorTimelineExample' => 'applications/uiexample/examples/PhabricatorTimelineExample.php', 'PhabricatorTimelineExample' => 'applications/uiexample/examples/PhabricatorTimelineExample.php',
'PhabricatorTimelineIterator' => 'infrastructure/daemon/timeline/cursor/PhabricatorTimelineIterator.php', 'PhabricatorTimelineIterator' => 'infrastructure/daemon/timeline/cursor/PhabricatorTimelineIterator.php',
'PhabricatorTimelineView' => 'view/layout/PhabricatorTimelineView.php', 'PhabricatorTimelineView' => 'view/layout/PhabricatorTimelineView.php',
'PhabricatorTimer' => 'applications/countdown/storage/PhabricatorTimer.php',
'PhabricatorToken' => 'applications/tokens/storage/PhabricatorToken.php', 'PhabricatorToken' => 'applications/tokens/storage/PhabricatorToken.php',
'PhabricatorTokenController' => 'applications/tokens/controller/PhabricatorTokenController.php', 'PhabricatorTokenController' => 'applications/tokens/controller/PhabricatorTokenController.php',
'PhabricatorTokenCount' => 'applications/tokens/storage/PhabricatorTokenCount.php', 'PhabricatorTokenCount' => 'applications/tokens/storage/PhabricatorTokenCount.php',
@ -2352,6 +2352,7 @@ phutil_register_library_map(array(
'ManiphestSavedQueryListController' => 'ManiphestController', 'ManiphestSavedQueryListController' => 'ManiphestController',
'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'ManiphestSubpriorityController' => 'ManiphestController', 'ManiphestSubpriorityController' => 'ManiphestController',
'ManiphestSubscribeController' => 'ManiphestController',
'ManiphestTask' => 'ManiphestTask' =>
array( array(
0 => 'ManiphestDAO', 0 => 'ManiphestDAO',
@ -2603,6 +2604,7 @@ phutil_register_library_map(array(
'PhabricatorContentSourceView' => 'AphrontView', 'PhabricatorContentSourceView' => 'AphrontView',
'PhabricatorController' => 'AphrontController', 'PhabricatorController' => 'AphrontController',
'PhabricatorCoreConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorCoreConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorCountdown' => 'PhabricatorCountdownDAO',
'PhabricatorCountdownController' => 'PhabricatorController', 'PhabricatorCountdownController' => 'PhabricatorController',
'PhabricatorCountdownDAO' => 'PhabricatorLiskDAO', 'PhabricatorCountdownDAO' => 'PhabricatorLiskDAO',
'PhabricatorCountdownDeleteController' => 'PhabricatorCountdownController', 'PhabricatorCountdownDeleteController' => 'PhabricatorCountdownController',
@ -3121,7 +3123,6 @@ phutil_register_library_map(array(
'PhabricatorTimelineExample' => 'PhabricatorUIExample', 'PhabricatorTimelineExample' => 'PhabricatorUIExample',
'PhabricatorTimelineIterator' => 'Iterator', 'PhabricatorTimelineIterator' => 'Iterator',
'PhabricatorTimelineView' => 'AphrontView', 'PhabricatorTimelineView' => 'AphrontView',
'PhabricatorTimer' => 'PhabricatorCountdownDAO',
'PhabricatorToken' => 'PhabricatorToken' =>
array( array(
0 => 'PhabricatorTokenDAO', 0 => 'PhabricatorTokenDAO',

View file

@ -8,9 +8,9 @@ abstract class PhabricatorCountdownController extends PhabricatorController {
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI())); $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
$nav->addFilter('', pht('All Timers'), $nav->addFilter('', pht('All Countdowns'),
$this->getApplicationURI('')); $this->getApplicationURI(''));
$nav->addFilter('', pht('Create Timer'), $nav->addFilter('', pht('Create Countdown'),
$this->getApplicationURI('edit/')); $this->getApplicationURI('edit/'));
return $nav; return $nav;
@ -25,7 +25,7 @@ abstract class PhabricatorCountdownController extends PhabricatorController {
$crumbs->addAction( $crumbs->addAction(
id(new PhabricatorMenuItemView()) id(new PhabricatorMenuItemView())
->setName(pht('Create Timer')) ->setName(pht('Create Countdown'))
->setHref($this->getApplicationURI('edit/')) ->setHref($this->getApplicationURI('edit/'))
->setIcon('create')); ->setIcon('create'));

View file

@ -14,7 +14,7 @@ final class PhabricatorCountdownDeleteController
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$timer = id(new PhabricatorTimer())->load($this->id); $timer = id(new PhabricatorCountdown())->load($this->id);
if (!$timer) { if (!$timer) {
return new Aphront404Response(); return new Aphront404Response();
} }

View file

@ -12,10 +12,10 @@ final class PhabricatorCountdownEditController
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$action_label = pht('Create Timer'); $action_label = pht('Create Countdown');
if ($this->id) { if ($this->id) {
$timer = id(new PhabricatorTimer())->load($this->id); $timer = id(new PhabricatorCountdown())->load($this->id);
// If no timer is found // If no timer is found
if (!$timer) { if (!$timer) {
return new Aphront404Response(); return new Aphront404Response();
@ -26,10 +26,10 @@ final class PhabricatorCountdownEditController
return new Aphront403Response(); return new Aphront403Response();
} }
$action_label = pht('Update Timer'); $action_label = pht('Update Countdown');
} else { } else {
$timer = new PhabricatorTimer(); $timer = new PhabricatorCountdown();
$timer->setDatePoint(time()); $timer->setEpoch(time());
} }
$error_view = null; $error_view = null;
@ -38,7 +38,7 @@ final class PhabricatorCountdownEditController
if ($request->isFormPost()) { if ($request->isFormPost()) {
$errors = array(); $errors = array();
$title = $request->getStr('title'); $title = $request->getStr('title');
$datepoint = $request->getStr('datepoint'); $epoch = $request->getStr('epoch');
$e_text = null; $e_text = null;
if (!strlen($title)) { if (!strlen($title)) {
@ -51,7 +51,7 @@ final class PhabricatorCountdownEditController
$timezone = new DateTimeZone($user->getTimezoneIdentifier()); $timezone = new DateTimeZone($user->getTimezoneIdentifier());
try { try {
$date = new DateTime($datepoint, $timezone); $date = new DateTime($epoch, $timezone);
$timestamp = $date->format('U'); $timestamp = $date->format('U');
} catch (Exception $e) { } catch (Exception $e) {
$errors[] = pht('You entered an incorrect date. You can enter date'. $errors[] = pht('You entered an incorrect date. You can enter date'.
@ -61,7 +61,7 @@ final class PhabricatorCountdownEditController
} }
$timer->setTitle($title); $timer->setTitle($title);
$timer->setDatePoint($timestamp); $timer->setEpoch($timestamp);
if (!count($errors)) { if (!count($errors)) {
$timer->setAuthorPHID($user->getPHID()); $timer->setAuthorPHID($user->getPHID());
@ -76,12 +76,12 @@ final class PhabricatorCountdownEditController
} }
} }
if ($timer->getDatePoint()) { if ($timer->getEpoch()) {
$display_datepoint = phabricator_datetime( $display_epoch = phabricator_datetime(
$timer->getDatePoint(), $timer->getEpoch(),
$user); $user);
} else { } else {
$display_datepoint = $request->getStr('datepoint'); $display_epoch = $request->getStr('epoch');
} }
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
@ -95,8 +95,8 @@ final class PhabricatorCountdownEditController
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel(pht('End date')) ->setLabel(pht('End date'))
->setValue($display_datepoint) ->setValue($display_epoch)
->setName('datepoint') ->setName('epoch')
->setCaption(pht('Examples: '. ->setCaption(pht('Examples: '.
'2011-12-25 or 3 hours or '. '2011-12-25 or 3 hours or '.
'June 8 2011, 5 PM.'))) 'June 8 2011, 5 PM.')))

View file

@ -12,7 +12,7 @@ final class PhabricatorCountdownListController
$pager->setOffset($request->getInt('page')); $pager->setOffset($request->getInt('page'));
$pager->setURI($request->getRequestURI(), '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', '1 = 1 ORDER BY id DESC LIMIT %d, %d',
$pager->getOffset(), $pager->getOffset(),
$pager->getPageSize() + 1); $pager->getPageSize() + 1);
@ -54,7 +54,7 @@ final class PhabricatorCountdownListController
'href' => '/countdown/'.$timer->getID().'/', 'href' => '/countdown/'.$timer->getID().'/',
), ),
$timer->getTitle()), $timer->getTitle()),
phabricator_datetime($timer->getDatepoint(), $user), phabricator_datetime($timer->getEpoch(), $user),
$edit_button, $edit_button,
$delete_button, $delete_button,
); );
@ -83,7 +83,7 @@ final class PhabricatorCountdownListController
$panel = id(new AphrontPanelView()) $panel = id(new AphrontPanelView())
->appendChild($table) ->appendChild($table)
->setHeader(pht('Timers')) ->setHeader(pht('Countdowns'))
->setNoBackground() ->setNoBackground()
->appendChild($pager); ->appendChild($pager);
@ -91,7 +91,7 @@ final class PhabricatorCountdownListController
->buildApplicationCrumbs() ->buildApplicationCrumbs()
->addCrumb( ->addCrumb(
id(new PhabricatorCrumbView()) id(new PhabricatorCrumbView())
->setName(pht('All Timers')) ->setName(pht('All Countdowns'))
->setHref($this->getApplicationURI())); ->setHref($this->getApplicationURI()));
return $this->buildApplicationPage( return $this->buildApplicationPage(

View file

@ -14,7 +14,7 @@ final class PhabricatorCountdownViewController
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$timer = id(new PhabricatorTimer())->load($this->id); $timer = id(new PhabricatorCountdown())->load($this->id);
if (!$timer) { if (!$timer) {
return new Aphront404Response(); return new Aphront404Response();
} }
@ -50,7 +50,7 @@ final class PhabricatorCountdownViewController
</div>', </div>',
$container, $container,
$timer->getTitle(), $timer->getTitle(),
phabricator_datetime($timer->getDatePoint(), $user), phabricator_datetime($timer->getEpoch(), $user),
pht('Days'), pht('Days'),
pht('Hours'), pht('Hours'),
pht('Minutes'), pht('Minutes'),
@ -62,7 +62,7 @@ final class PhabricatorCountdownViewController
$chrome_link); $chrome_link);
Javelin::initBehavior('countdown-timer', array( Javelin::initBehavior('countdown-timer', array(
'timestamp' => $timer->getDatepoint(), 'timestamp' => $timer->getEpoch(),
'container' => $container, 'container' => $container,
)); ));

View file

@ -15,7 +15,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule {
} }
protected function markupCountdown($matches) { protected function markupCountdown($matches) {
$countdown = id(new PhabricatorTimer())->load($matches[1]); $countdown = id(new PhabricatorCountdown())->load($matches[1]);
if (!$countdown) { if (!$countdown) {
return $matches[0]; return $matches[0];
} }
@ -23,7 +23,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule {
$engine = $this->getEngine(); $engine = $this->getEngine();
if ($engine->isTextMode()) { if ($engine->isTextMode()) {
$date = $countdown->getDatepoint(); $date = $countdown->getEpoch();
$viewer = $engine->getConfig('viewer'); $viewer = $engine->getConfig('viewer');
if ($viewer) { if ($viewer) {
$date = phabricator_datetime($date, $viewer); $date = phabricator_datetime($date, $viewer);
@ -36,7 +36,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule {
$metadata_key = self::KEY_RULE_COUNTDOWN; $metadata_key = self::KEY_RULE_COUNTDOWN;
$metadata = $engine->getTextMetadata($metadata_key, array()); $metadata = $engine->getTextMetadata($metadata_key, array());
$metadata[$id] = array($countdown->getDatepoint(), $token); $metadata[$id] = array($countdown->getEpoch(), $token);
$engine->setTextMetadata($metadata_key, $metadata); $engine->setTextMetadata($metadata_key, $metadata);
return $token; return $token;

View file

@ -0,0 +1,21 @@
<?php
final class PhabricatorCountdown extends PhabricatorCountdownDAO {
protected $id;
protected $phid;
protected $title;
protected $authorPHID;
protected $epoch;
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID('CDWN');
}
}

View file

@ -1,10 +0,0 @@
<?php
final class PhabricatorTimer extends PhabricatorCountdownDAO {
protected $id;
protected $title;
protected $authorPHID;
protected $datepoint;
}

View file

@ -1258,6 +1258,18 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql', 'type' => 'sql',
'name' => $this->getPatchPath('20130426.search_savedquery.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'),
),
); );
} }
} }