Page MenuHomePhorge

Conduit column.search: add status, sequence and isDefault to API results
Needs ReviewPublic

Authored by 20after4 on Apr 24 2022, 18:29.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 3, 17:47
Unknown Object (File)
Sat, Jun 3, 17:47
Unknown Object (File)
Sat, Jun 3, 17:47
Unknown Object (File)
Sat, Jun 3, 17:47
Unknown Object (File)
Sat, Jun 3, 17:47
Unknown Object (File)
Thu, Jun 1, 00:18
Unknown Object (File)
Wed, May 31, 05:57
Unknown Object (File)
Sun, May 14, 17:34

Details

Summary

This seems like a fairly obvious oversight with the column.search API.

Knowing:

  1. the status (active vs archived)
  2. isDefaultColumn (the one that tasks get dropped in by default)
  3. sequence (order on the workboard)

are all necessary for a lot of things that very sensible real-world API clients need to do when working with columns.

Cherry-picked from https://phabricator.wikimedia.org/rPHABebfe30890b52784d222ec4ed36c05462b2a57f92

Test Plan

Tested on phabricator.wikimedia.org over many months and used by real client apps.

Diff Detail

Repository
rP Phorge
Branch
phorge.it (branched from master)
Lint
Lint Warnings
SeverityLocationCodeMessage
Warningsrc/applications/project/storage/PhabricatorProjectColumn.php:285TXT3Line Too Long
Unit
Test Failures
Build Status
Buildable 67
Build 67: arc lint + arc unit

Unit TestsFailed

TimeTest
115 msPhabricatorCelerityTestCase::testCelerityMaps
Assertion failed, expected 'true' (at PhabricatorCelerityTestCase.php:32): When this test fails, it means the Celerity resource map is out of date. Run `bin/celerity map` to rebuild it. ACTUAL VALUE
13 msPhabricatorConduitTestCase::testConduitMethods
1 assertion passed.
0 msPhabricatorInfrastructureTestCase::testApplicationsInstalled
1 assertion passed.
0 msPhabricatorInfrastructureTestCase::testRejectMySQLNonUTF8Queries
1 assertion passed.
433 msPhabricatorLibraryTestCase::testEverythingImplemented
1 assertion passed.
View Full Test Results (1 Failed · 29 Passed)

Event Timeline

20after4 retitled this revision from Add column sequence to the conduit api results for column.search to Add Status, sequence and isDefault to the conduit api results for column.search.Apr 24 2022, 18:34
20after4 edited the summary of this revision. (Show Details)
0 requested changes to this revision.May 22 2022, 19:22
0 added a subscriber: 0.
0 added inline comments.
src/applications/project/storage/PhabricatorProjectColumn.php
276

It seems odd to return the strings "0" and "1" for the status. Unless there's a reason to do this, an integer would be more reasonable. Even better would be an array containing the keys "value" and "name", like in a few other status fields.

281

The existing bool fields use the language "True if ..." rather than "Whether ...".

This revision now requires changes to proceed.May 22 2022, 19:22

Thank you @20after4 for this patch. The inline comments seem reasonable to me. What do you think about?

avivey added a reviewer: 20after4.
  • change language and replace "status" with "isHidden"
  • celerify

(I haven't seen @20after4 for a while now. Also @0).

src/applications/project/storage/PhabricatorProjectColumn.php
294

Should the key be changed to match?

src/applications/project/storage/PhabricatorProjectColumn.php
294

Yes, they should :)

I tested this locally and it works, thank you.

The only strange thing is that the sequence field is supposed - internally - to be an integer but it's exposed as a string in this API.

I say, that it's supposed to be an int, since I noticed:

PhabricatorBoardLayoutEngine.php
$next_sequence = last($board_columns)->getSequence() + 1;

And:

PhabricatorProjectColumnPosition.php
->addInt($this->getSequence())

So, I suggest to expose the sequence field as an integer, and not as a string.

In case, I suggest to return an int just from the API, without touching in any way the PhabricatorEdgeObject#getSequence() - in this moment.

src/applications/project/storage/PhabricatorProjectColumn.php
296

As already mentioned I would recommend to return an integer here since all the known business logic of that information assume that as an integer, and so the API consumers should assume that as an integer.

I'm not opinionated about how, but maybe a single cast can do the job instead of doing a refactor, for now.

valerio.bozzolan retitled this revision from Add Status, sequence and isDefault to the conduit api results for column.search to Conduit column.search: add status, sequence and isDefault to API results.Apr 7 2023, 21:58
valerio.bozzolan edited the summary of this revision. (Show Details)
valerio.bozzolan edited reviewers, added: avivey; removed: valerio.bozzolan.

@20after4 do you agree in exposing the sequence as an integer? (since it's assumed to be an integer internally)