mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-16 18:40:54 +01:00
2d87bb29ac
Summary: this let's the list controller save a query. Fixes T3488. Note didn't bother denormalizing document body at all since I don't think we want to show a snippet. Test Plan: viewed a list of legalpad documents - yay. viewed a legalpad document - yay. created a legalpad document - yay. edited a legalpad document - yay. edited with N authors - yay. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T3488 Differential Revision: https://secure.phabricator.com/D6382
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
echo "Populating Legalpad Documents with ",
|
|
"titles, recentContributorPHIDs, and contributorCounts...\n";
|
|
$table = new LegalpadDocument();
|
|
$table->openTransaction();
|
|
|
|
foreach (new LiskMigrationIterator($table) as $document) {
|
|
$updated = false;
|
|
$id = $document->getID();
|
|
|
|
echo "Document {$id}: ";
|
|
if (!$document->getTitle()) {
|
|
$document_body = id(new LegalpadDocumentBody())
|
|
->loadOneWhere('phid = %s', $document->getDocumentBodyPHID());
|
|
$title = $document_body->getTitle();
|
|
$document->setTitle($title);
|
|
$updated = true;
|
|
echo "Added title: $title\n";
|
|
} else {
|
|
echo "-\n";
|
|
}
|
|
|
|
if (!$document->getContributorCount() ||
|
|
!$document->getRecentContributorPHIDs()) {
|
|
$updated = true;
|
|
$type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_CONTRIBUTOR;
|
|
$contributors = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
$document->getPHID(),
|
|
$type);
|
|
$document->setRecentContributorPHIDs(array_slice($contributors, 0, 3));
|
|
echo "Added recent contributor phids.\n";
|
|
$document->setContributorCount(count($contributors));
|
|
echo "Added contributor count.\n";
|
|
}
|
|
|
|
if (!$updated) {
|
|
echo "-\n";
|
|
continue;
|
|
}
|
|
|
|
$document->save();
|
|
}
|
|
|
|
$table->saveTransaction();
|
|
echo "Done.\n";
|