2012-01-11 04:51:55 +01:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class ManiphestGetTaskTransactionsConduitAPIMethod
|
|
|
|
extends ManiphestConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'maniphest.gettasktransactions';
|
|
|
|
}
|
2012-01-11 04:51:55 +01:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return 'Retrieve Maniphest Task Transactions.';
|
2012-01-11 04:51:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function defineParamTypes() {
|
|
|
|
return array(
|
|
|
|
'ids' => 'required list<int>',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineReturnType() {
|
|
|
|
return 'nonempty list<dict<string, wild>>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function defineErrorTypes() {
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$results = array();
|
|
|
|
$task_ids = $request->getValue('ids');
|
|
|
|
|
|
|
|
if (!$task_ids) {
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
2013-09-23 23:25:14 +02:00
|
|
|
$tasks = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($request->getUser())
|
|
|
|
->withIDs($task_ids)
|
|
|
|
->execute();
|
Migrate all Maniphest transaction data to new storage
Summary:
Ref T2217. This is the risky, hard part; everything after this should be smooth sailing. This is //mostly// clean, except:
- The old format would opportunistically combine a comment with some other transaction type if it could. We no longer do that, so:
- When migrating, "edit" + "comment" transactions need to be split in two.
- When editing now, we should no longer combine these transaction types.
- These changes are pretty straightforward and low-impact.
- This migration promotes "auxiliary field" data to the new CustomField/StandardField format, so that's not a straight migration either. The formats are very similar, though.
Broadly, this takes the same attack that the auth migration did: proxy all the code through to the new storage. `ManiphestTransaction` is now just an API on top of `ManiphestTransactionPro`, which is the new storage format. The two formats are very similar, so this was mostly a straight copy from one table to the other.
Test Plan:
- Without performing the migration, made a bunch of edits and comments on tasks and verified the new code works correctly.
- Droped the test data and performed the migration.
- Looked at the resulting data for obvious discrepancies.
- Looked at a bunch of tasks and their transaction history.
- Used Conduit to pull transaction data.
- Edited task description and clicked "View Details" on transaction.
- Used batch editor.
- Made a bunch more edits.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2217
Differential Revision: https://secure.phabricator.com/D7068
2013-09-23 23:25:28 +02:00
|
|
|
$tasks = mpull($tasks, null, 'getPHID');
|
2013-09-23 23:25:14 +02:00
|
|
|
|
2013-09-23 23:30:54 +02:00
|
|
|
$transactions = array();
|
|
|
|
if ($tasks) {
|
|
|
|
$transactions = id(new ManiphestTransactionQuery())
|
|
|
|
->setViewer($request->getUser())
|
|
|
|
->withObjectPHIDs(mpull($tasks, 'getPHID'))
|
|
|
|
->needComments(true)
|
|
|
|
->execute();
|
|
|
|
}
|
2012-01-11 04:51:55 +01:00
|
|
|
|
|
|
|
foreach ($transactions as $transaction) {
|
2013-09-23 23:30:54 +02:00
|
|
|
$task_phid = $transaction->getObjectPHID();
|
Migrate all Maniphest transaction data to new storage
Summary:
Ref T2217. This is the risky, hard part; everything after this should be smooth sailing. This is //mostly// clean, except:
- The old format would opportunistically combine a comment with some other transaction type if it could. We no longer do that, so:
- When migrating, "edit" + "comment" transactions need to be split in two.
- When editing now, we should no longer combine these transaction types.
- These changes are pretty straightforward and low-impact.
- This migration promotes "auxiliary field" data to the new CustomField/StandardField format, so that's not a straight migration either. The formats are very similar, though.
Broadly, this takes the same attack that the auth migration did: proxy all the code through to the new storage. `ManiphestTransaction` is now just an API on top of `ManiphestTransactionPro`, which is the new storage format. The two formats are very similar, so this was mostly a straight copy from one table to the other.
Test Plan:
- Without performing the migration, made a bunch of edits and comments on tasks and verified the new code works correctly.
- Droped the test data and performed the migration.
- Looked at the resulting data for obvious discrepancies.
- Looked at a bunch of tasks and their transaction history.
- Used Conduit to pull transaction data.
- Edited task description and clicked "View Details" on transaction.
- Used batch editor.
- Made a bunch more edits.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2217
Differential Revision: https://secure.phabricator.com/D7068
2013-09-23 23:25:28 +02:00
|
|
|
if (empty($tasks[$task_phid])) {
|
|
|
|
continue;
|
2012-01-11 04:51:55 +01:00
|
|
|
}
|
Migrate all Maniphest transaction data to new storage
Summary:
Ref T2217. This is the risky, hard part; everything after this should be smooth sailing. This is //mostly// clean, except:
- The old format would opportunistically combine a comment with some other transaction type if it could. We no longer do that, so:
- When migrating, "edit" + "comment" transactions need to be split in two.
- When editing now, we should no longer combine these transaction types.
- These changes are pretty straightforward and low-impact.
- This migration promotes "auxiliary field" data to the new CustomField/StandardField format, so that's not a straight migration either. The formats are very similar, though.
Broadly, this takes the same attack that the auth migration did: proxy all the code through to the new storage. `ManiphestTransaction` is now just an API on top of `ManiphestTransactionPro`, which is the new storage format. The two formats are very similar, so this was mostly a straight copy from one table to the other.
Test Plan:
- Without performing the migration, made a bunch of edits and comments on tasks and verified the new code works correctly.
- Droped the test data and performed the migration.
- Looked at the resulting data for obvious discrepancies.
- Looked at a bunch of tasks and their transaction history.
- Used Conduit to pull transaction data.
- Edited task description and clicked "View Details" on transaction.
- Used batch editor.
- Made a bunch more edits.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2217
Differential Revision: https://secure.phabricator.com/D7068
2013-09-23 23:25:28 +02:00
|
|
|
|
|
|
|
$task_id = $tasks[$task_phid]->getID();
|
|
|
|
|
2013-09-23 23:30:54 +02:00
|
|
|
$comments = null;
|
|
|
|
if ($transaction->hasComment()) {
|
|
|
|
$comments = $transaction->getComment()->getContent();
|
|
|
|
}
|
|
|
|
|
2012-01-11 04:51:55 +01:00
|
|
|
$results[$task_id][] = array(
|
|
|
|
'taskID' => $task_id,
|
2014-11-24 23:59:52 +01:00
|
|
|
'transactionPHID' => $transaction->getPHID(),
|
2012-01-11 04:51:55 +01:00
|
|
|
'transactionType' => $transaction->getTransactionType(),
|
|
|
|
'oldValue' => $transaction->getOldValue(),
|
|
|
|
'newValue' => $transaction->getNewValue(),
|
2013-09-23 23:30:54 +02:00
|
|
|
'comments' => $comments,
|
2012-01-11 04:51:55 +01:00
|
|
|
'authorPHID' => $transaction->getAuthorPHID(),
|
|
|
|
'dateCreated' => $transaction->getDateCreated(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
2014-07-10 00:12:48 +02:00
|
|
|
|
2012-01-11 04:51:55 +01:00
|
|
|
}
|