Page MenuHomePhabricator

Add authorPHID to Dashboards
ClosedPublic

Authored by chad on Dec 10 2016, 11:45 PM.
Tags
None
Referenced Files
F14033903: D17022.diff
Sat, Nov 9, 8:39 PM
F14020946: D17022.diff
Wed, Nov 6, 3:50 AM
F14010706: D17022.diff
Thu, Oct 31, 11:53 AM
F13998550: D17022.diff
Thu, Oct 24, 9:46 AM
F13980538: D17022.id40949.diff
Sat, Oct 19, 11:18 AM
Unknown Object (File)
Sep 27 2024, 2:07 PM
Unknown Object (File)
Sep 22 2024, 4:25 PM
Unknown Object (File)
Sep 10 2024, 12:11 AM
Subscribers
Tokens
"100" token, awarded by ajax404.

Details

Summary

Adds an authorPHIDs, populates olds ones.

Test Plan

Make a new Dashboard, see that I created it.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

chad retitled this revision from to Add authorPHID to Dashboards.
chad updated this object.
chad edited the test plan for this revision. (Show Details)
chad added a reviewer: epriestley.
epriestley edited edge metadata.

Let's make the column non-nullable since it will always be populated going forward.

You can backpopulate it by writing a migration that does this:

  • Iterate over every dashboard.
  • For each dashboard, select the authorPHID of the first transaction which applied to the dashboard, something like SELECT authorPHID FROM %T WHERE objectPHID = %s ORDER BY id ASC LIMIT 1
  • If there's no such transaction, just use the Dashboards application PHID so the UI doesn't get too goofy? This should be rare.
src/applications/dashboard/query/PhabricatorDashboardQuery.php
29

To be more explicit, prefer withAuthorPHIDs().

src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
23

For consistency, prefer to use authorPHIDs as the internal key.

You can use setAliases(array('author', 'authors', 'authored', 'authorPHID')) or similar if you want to support more readable GET parameters.

This revision now requires changes to proceed.Dec 12 2016, 4:07 PM
chad edited edge metadata.
  • populate authorPHID
chad edited edge metadata.
resources/sql/autopatches/21061210.dashboards.01.author.php
22 ↗(On Diff #40976)

is this correct?

epriestley edited edge metadata.

One actual issue and a couple of nitpicks. Like 98% of this is correct.

resources/sql/autopatches/20161210.dashboards.01.author.sql
2–3

Should be NOT NULL now.

resources/sql/autopatches/21061210.dashboards.01.author.php
14 ↗(On Diff #40976)

Maybe do if ($dashboard->getAuthorPHID()) { continue; } here so we don't mess anything up if someone accidentally runs this later and the data is whack.

22 ↗(On Diff #40976)

I don't think this will work, since we access $author_phid['authorPHID'] below, but we're just assigning a plain PHID here. Maybe call the first variable $author_row, then derive $author_phid here?

if (!$author_row) {
  $author_phid = // application PHID
} else {
  $author_phid = $author_row['authorPHID'];
}

Then just use plain $author_phid below.

You can re-run this to test your changes by doing UPDATE whatever SET authorPHID = '', then using bin/storage upgrade --apply phabricator:2016110....

src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
24

Oh, also maybe this should be PhabricatorPeopleUserFunctionDatasource since viewer() should work here.

src/applications/dashboard/storage/PhabricatorDashboard.php
66

Just phid now?

This revision now requires changes to proceed.Dec 12 2016, 10:08 PM
chad edited edge metadata.
chad marked 5 inline comments as done.
  • per comments
epriestley edited edge metadata.
This revision is now accepted and ready to land.Dec 12 2016, 11:25 PM
This revision was automatically updated to reflect the committed changes.