mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Merge the "HarbormasterBuildCommand" table into "HarbormasterBuildMessage"
Summary: Ref T13072. These two similar tables don't make sense to keep separate. Instead, make Build a valid receiver for BuildMessage objects. These tables are practically the same, so this is straightforward: just copy the rows in and then drop the old table. (This table was trivial and ephemeral anyway, so I'm not bothering to do the usual "keep it around for a couple years just in case".) Test Plan: - Populated BuildCommand table, ran migration, saw Builds end up in the proper transitional state (e.g., pausing, aborting, restarting) with appropriate queued messages. - Queued new messages by clicking UI buttons. - Ran BuildWorkers, saw them process messages and mark them as consumed. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13072 Differential Revision: https://secure.phabricator.com/D21684
This commit is contained in:
parent
0f93d1ffe4
commit
b48d4fabaf
7 changed files with 26 additions and 32 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
INSERT IGNORE INTO {$NAMESPACE}_harbormaster.harbormaster_buildmessage
|
||||||
|
(authorPHID, receiverPHID, type, isConsumed, dateCreated, dateModified)
|
||||||
|
SELECT authorPHID, targetPHID, command, 0, dateCreated, dateModified
|
||||||
|
FROM {$NAMESPACE}_harbormaster.harbormaster_buildcommand;
|
|
@ -0,0 +1 @@
|
||||||
|
DROP TABLE IF EXISTS {$NAMESPACE}_harbormaster.harbormaster_buildcommand;
|
|
@ -7597,7 +7597,7 @@ phutil_register_library_map(array(
|
||||||
'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType',
|
'HarbormasterBuildArtifactPHIDType' => 'PhabricatorPHIDType',
|
||||||
'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'HarbormasterBuildAutoplan' => 'Phobject',
|
'HarbormasterBuildAutoplan' => 'Phobject',
|
||||||
'HarbormasterBuildCommand' => 'HarbormasterDAO',
|
'HarbormasterBuildCommand' => 'Phobject',
|
||||||
'HarbormasterBuildDependencyDatasource' => 'PhabricatorTypeaheadDatasource',
|
'HarbormasterBuildDependencyDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'HarbormasterBuildEngine' => 'Phobject',
|
'HarbormasterBuildEngine' => 'Phobject',
|
||||||
'HarbormasterBuildFailureException' => 'Exception',
|
'HarbormasterBuildFailureException' => 'Exception',
|
||||||
|
|
|
@ -93,10 +93,10 @@ final class HarbormasterBuildTransactionEditor
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
id(new HarbormasterBuildCommand())
|
HarbormasterBuildMessage::initializeNewMessage($actor)
|
||||||
->setAuthorPHID($xaction->getAuthorPHID())
|
->setAuthorPHID($xaction->getAuthorPHID())
|
||||||
->setTargetPHID($build->getPHID())
|
->setReceiverPHID($build->getPHID())
|
||||||
->setCommand($command)
|
->setType($command)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
PhabricatorWorker::scheduleTask(
|
PhabricatorWorker::scheduleTask(
|
||||||
|
|
|
@ -104,10 +104,10 @@ final class HarbormasterBuildQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
$build_phids = mpull($page, 'getPHID');
|
$build_phids = mpull($page, 'getPHID');
|
||||||
$messages = id(new HarbormasterBuildCommand())->loadAllWhere(
|
$messages = id(new HarbormasterBuildMessage())->loadAllWhere(
|
||||||
'targetPHID IN (%Ls) ORDER BY id ASC',
|
'receiverPHID IN (%Ls) AND isConsumed = 0 ORDER BY id ASC',
|
||||||
$build_phids);
|
$build_phids);
|
||||||
$messages = mgroup($messages, 'getTargetPHID');
|
$messages = mgroup($messages, 'getReceiverPHID');
|
||||||
foreach ($page as $build) {
|
foreach ($page as $build) {
|
||||||
$unprocessed_messages = idx($messages, $build->getPHID(), array());
|
$unprocessed_messages = idx($messages, $build->getPHID(), array());
|
||||||
$build->attachUnprocessedMessages($unprocessed_messages);
|
$build->attachUnprocessedMessages($unprocessed_messages);
|
||||||
|
|
|
@ -1,27 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class HarbormasterBuildCommand extends HarbormasterDAO {
|
final class HarbormasterBuildCommand
|
||||||
|
extends Phobject {
|
||||||
|
|
||||||
const COMMAND_PAUSE = 'pause';
|
const COMMAND_PAUSE = 'pause';
|
||||||
const COMMAND_RESUME = 'resume';
|
const COMMAND_RESUME = 'resume';
|
||||||
const COMMAND_RESTART = 'restart';
|
const COMMAND_RESTART = 'restart';
|
||||||
const COMMAND_ABORT = 'abort';
|
const COMMAND_ABORT = 'abort';
|
||||||
|
|
||||||
protected $authorPHID;
|
|
||||||
protected $targetPHID;
|
|
||||||
protected $command;
|
|
||||||
|
|
||||||
protected function getConfiguration() {
|
|
||||||
return array(
|
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
|
||||||
'command' => 'text128',
|
|
||||||
),
|
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
|
||||||
'key_target' => array(
|
|
||||||
'columns' => array('targetPHID'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
) + parent::getConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,6 +230,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachUnprocessedMessages(array $messages) {
|
public function attachUnprocessedMessages(array $messages) {
|
||||||
|
assert_instances_of($messages, 'HarbormasterBuildMessage');
|
||||||
$this->unprocessedMessages = $messages;
|
$this->unprocessedMessages = $messages;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +332,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
public function isPausing() {
|
public function isPausing() {
|
||||||
$is_pausing = false;
|
$is_pausing = false;
|
||||||
foreach ($this->getUnprocessedMessages() as $message_object) {
|
foreach ($this->getUnprocessedMessages() as $message_object) {
|
||||||
$message_type = $message_object->getCommand();
|
$message_type = $message_object->getType();
|
||||||
switch ($message_type) {
|
switch ($message_type) {
|
||||||
case HarbormasterBuildCommand::COMMAND_PAUSE:
|
case HarbormasterBuildCommand::COMMAND_PAUSE:
|
||||||
$is_pausing = true;
|
$is_pausing = true;
|
||||||
|
@ -352,7 +353,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
public function isResuming() {
|
public function isResuming() {
|
||||||
$is_resuming = false;
|
$is_resuming = false;
|
||||||
foreach ($this->getUnprocessedMessages() as $message_object) {
|
foreach ($this->getUnprocessedMessages() as $message_object) {
|
||||||
$message_type = $message_object->getCommand();
|
$message_type = $message_object->getType();
|
||||||
switch ($message_type) {
|
switch ($message_type) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
case HarbormasterBuildCommand::COMMAND_RESUME:
|
case HarbormasterBuildCommand::COMMAND_RESUME:
|
||||||
|
@ -373,7 +374,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
public function isRestarting() {
|
public function isRestarting() {
|
||||||
$is_restarting = false;
|
$is_restarting = false;
|
||||||
foreach ($this->getUnprocessedMessages() as $message_object) {
|
foreach ($this->getUnprocessedMessages() as $message_object) {
|
||||||
$message_type = $message_object->getCommand();
|
$message_type = $message_object->getType();
|
||||||
switch ($message_type) {
|
switch ($message_type) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
$is_restarting = true;
|
$is_restarting = true;
|
||||||
|
@ -387,7 +388,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
public function isAborting() {
|
public function isAborting() {
|
||||||
$is_aborting = false;
|
$is_aborting = false;
|
||||||
foreach ($this->getUnprocessedMessages() as $message_object) {
|
foreach ($this->getUnprocessedMessages() as $message_object) {
|
||||||
$message_type = $message_object->getCommand();
|
$message_type = $message_object->getType();
|
||||||
switch ($message_type) {
|
switch ($message_type) {
|
||||||
case HarbormasterBuildCommand::COMMAND_ABORT:
|
case HarbormasterBuildCommand::COMMAND_ABORT:
|
||||||
$is_aborting = true;
|
$is_aborting = true;
|
||||||
|
@ -399,9 +400,13 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markUnprocessedMessagesAsProcessed() {
|
public function markUnprocessedMessagesAsProcessed() {
|
||||||
// TODO: See T13072. This is a placeholder until BuildCommand and
|
foreach ($this->getUnprocessedMessages() as $key => $message_object) {
|
||||||
// BuildMessage merge.
|
$message_object
|
||||||
return $this->deleteUnprocessedMessages();
|
->setIsConsumed(1)
|
||||||
|
->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteUnprocessedMessages() {
|
public function deleteUnprocessedMessages() {
|
||||||
|
|
Loading…
Reference in a new issue