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

Generate expected Ponder schemata

Summary:
Ref T1191.

  - Removes ponder comment table. This was migrated a very long time ago.

Test Plan:
  - Grepped for removed table.
  - Saw ~100 fewer issues in web UI.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1191

Differential Revision: https://secure.phabricator.com/D10582
This commit is contained in:
epriestley 2014-10-01 07:37:14 -07:00
parent ac9182af58
commit 152a62db7a
9 changed files with 77 additions and 135 deletions

View file

@ -0,0 +1 @@
DROP TABLE {$NAMESPACE}_ponder.ponder_comment;

View file

@ -2688,8 +2688,6 @@ phutil_register_library_map(array(
'PonderAnswerTransaction' => 'applications/ponder/storage/PonderAnswerTransaction.php',
'PonderAnswerTransactionComment' => 'applications/ponder/storage/PonderAnswerTransactionComment.php',
'PonderAnswerTransactionQuery' => 'applications/ponder/query/PonderAnswerTransactionQuery.php',
'PonderComment' => 'applications/ponder/storage/PonderComment.php',
'PonderCommentQuery' => 'applications/ponder/query/PonderCommentQuery.php',
'PonderConstants' => 'applications/ponder/constants/PonderConstants.php',
'PonderController' => 'applications/ponder/controller/PonderController.php',
'PonderDAO' => 'applications/ponder/storage/PonderDAO.php',
@ -2712,6 +2710,7 @@ phutil_register_library_map(array(
'PonderQuestionTransactionQuery' => 'applications/ponder/query/PonderQuestionTransactionQuery.php',
'PonderQuestionViewController' => 'applications/ponder/controller/PonderQuestionViewController.php',
'PonderRemarkupRule' => 'applications/ponder/remarkup/PonderRemarkupRule.php',
'PonderSchemaSpec' => 'applications/ponder/storage/PonderSchemaSpec.php',
'PonderSearchIndexer' => 'applications/ponder/search/PonderSearchIndexer.php',
'PonderTransactionFeedStory' => 'applications/ponder/feed/PonderTransactionFeedStory.php',
'PonderVotableInterface' => 'applications/ponder/storage/PonderVotableInterface.php',
@ -5759,11 +5758,6 @@ phutil_register_library_map(array(
'PonderAnswerTransaction' => 'PhabricatorApplicationTransaction',
'PonderAnswerTransactionComment' => 'PhabricatorApplicationTransactionComment',
'PonderAnswerTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PonderComment' => array(
'PonderDAO',
'PhabricatorMarkupInterface',
),
'PonderCommentQuery' => 'PhabricatorQuery',
'PonderController' => 'PhabricatorController',
'PonderDAO' => 'PhabricatorLiskDAO',
'PonderEditor' => 'PhabricatorApplicationTransactionEditor',
@ -5795,6 +5789,7 @@ phutil_register_library_map(array(
'PonderQuestionTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PonderQuestionViewController' => 'PonderController',
'PonderRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PonderSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PonderSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'PonderTransactionFeedStory' => 'PhabricatorApplicationTransactionFeedStory',
'PonderVotableView' => 'AphrontView',

View file

@ -144,8 +144,10 @@ final class PhabricatorConfigDatabaseIssueController
new PhutilNumber($counts[PhabricatorConfigStorageSchema::STATUS_NOTE]));
}
$title = pht('Database Issues');
$table_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Database Issues'))
->setHeaderText($title)
->setFormErrors($errors)
->appendChild($table);
@ -160,7 +162,7 @@ final class PhabricatorConfigDatabaseIssueController
return $this->buildApplicationPage(
$nav,
array(
'title' => 'all',
'title' => $title,
));
}

View file

@ -233,6 +233,9 @@ abstract class PhabricatorConfigSchemaSpec extends Phobject {
case 'uint32':
$column_type = 'int(10) unsigned';
break;
case 'sint32':
$column_type = 'int(10)';
break;
case 'id64':
case 'uint64':
$column_type = 'bigint(20) unsigned';

View file

@ -1,65 +0,0 @@
<?php
final class PonderCommentQuery extends PhabricatorQuery {
private $ids;
private $authorPHID;
private $targetPHIDs;
public function withIDs($qids) {
$this->ids = $qids;
return $this;
}
public function withTargetPHIDs($phids) {
$this->targetPHIDs = $phids;
return $this;
}
public function withAuthorPHID($phid) {
$this->authorPHID = $phid;
return $this;
}
private function buildWhereClause($conn_r) {
$where = array();
if ($this->ids) {
$where[] = qsprintf($conn_r, 'id in (%Ls)', $this->ids);
}
if ($this->authorPHID) {
$where[] = qsprintf($conn_r, 'authorPHID = %s', $this->authorPHID);
}
if ($this->targetPHIDs) {
$where[] = qsprintf($conn_r, 'targetPHID in (%Ls)', $this->targetPHIDs);
}
return $this->formatWhereClause($where);
}
private function buildOrderByClause($conn_r) {
return 'ORDER BY id';
}
public function execute() {
$comment = new PonderComment();
$conn_r = $comment->establishConnection('r');
$select = qsprintf(
$conn_r,
'SELECT r.* FROM %T r',
$comment->getTableName());
$where = $this->buildWhereClause($conn_r);
$order_by = $this->buildOrderByClause($conn_r);
return $comment->loadAllFromArray(
queryfx_all(
$conn_r,
'%Q %Q %Q',
$select,
$where,
$order_by));
}
}

View file

@ -67,6 +67,28 @@ final class PonderAnswer extends PonderDAO
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'voteCount' => 'sint32',
'content' => 'text',
'contentSource' => 'text',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
'phid' => array(
'columns' => array('phid'),
'unique' => true,
),
'key_oneanswerperquestion' => array(
'columns' => array('questionID', 'authorPHID'),
'unique' => true,
),
'questionID' => array(
'columns' => array('questionID'),
),
'authorPHID' => array(
'columns' => array('authorPHID'),
),
),
) + parent::getConfiguration();
}

View file

@ -1,40 +0,0 @@
<?php
final class PonderComment extends PonderDAO
implements PhabricatorMarkupInterface {
const MARKUP_FIELD_CONTENT = 'markup:content';
protected $targetPHID;
protected $authorPHID;
protected $content;
public function getMarkupFieldKey($field) {
$hash = PhabricatorHash::digest($this->getMarkupText($field));
$id = $this->getID();
return "ponder:c{$id}:{$field}:{$hash}";
}
public function getMarkupText($field) {
return $this->getContent();
}
public function newMarkupEngine($field) {
return PhabricatorMarkupEngine::getEngine();
}
public function didMarkupText(
$field,
$output,
PhutilMarkupEngine $engine) {
return $output;
}
public function shouldUseMarkupCache($field) {
return (bool)$this->getID();
}
public function getMarkupField() {
return self::MARKUP_FIELD_CONTENT;
}
}

View file

@ -33,6 +33,32 @@ final class PonderQuestion extends PonderDAO
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'title' => 'text255',
'voteCount' => 'sint32',
'status' => 'uint32',
'content' => 'text',
'contentSource' => 'text',
'heat' => 'double',
'answerCount' => 'uint32',
'mailKey' => 'bytes20',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
'phid' => array(
'columns' => array('phid'),
'unique' => true,
),
'authorPHID' => array(
'columns' => array('authorPHID'),
),
'heat' => array(
'columns' => array('heat'),
),
'status' => array(
'columns' => array('status'),
),
),
) + parent::getConfiguration();
}
@ -49,27 +75,6 @@ final class PonderQuestion extends PonderDAO
return PhabricatorContentSource::newFromSerialized($this->contentSource);
}
public function attachRelated() {
$this->answers = $this->loadRelatives(new PonderAnswer(), 'questionID');
$qa_phids = mpull($this->answers, 'getPHID') + array($this->getPHID());
if ($qa_phids) {
$comments = id(new PonderCommentQuery())
->withTargetPHIDs($qa_phids)
->execute();
$comments = mgroup($comments, 'getTargetPHID');
} else {
$comments = array();
}
$this->setComments(idx($comments, $this->getPHID(), array()));
foreach ($this->answers as $answer) {
$answer->attachQuestion($this);
$answer->setComments(idx($comments, $answer->getPHID(), array()));
}
}
public function attachVotes($user_phid) {
$qa_phids = mpull($this->answers, 'getPHID') + array($this->getPHID());

View file

@ -0,0 +1,19 @@
<?php
final class PonderSchemaSpec extends PhabricatorConfigSchemaSpec {
public function buildSchemata() {
$this->buildLiskSchemata('PonderDAO');
$this->buildEdgeSchemata(new PonderQuestion());
$this->buildTransactionSchema(
new PonderQuestionTransaction(),
new PonderQuestionTransactionComment());
$this->buildTransactionSchema(
new PonderAnswerTransaction(),
new PonderAnswerTransactionComment());
}
}