Page MenuHomePhabricator

Allow Phame Posts to be ordered by datePublished
ClosedPublic

Authored by chad on Jun 15 2016, 6:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 8, 10:42 PM
Unknown Object (File)
Sun, Dec 8, 1:36 PM
Unknown Object (File)
Fri, Dec 6, 5:19 PM
Unknown Object (File)
Thu, Dec 5, 9:04 AM
Unknown Object (File)
Mon, Dec 2, 7:55 PM
Unknown Object (File)
Sat, Nov 30, 4:58 PM
Unknown Object (File)
Tue, Nov 26, 6:31 PM
Unknown Object (File)
Sat, Nov 23, 3:09 AM
Subscribers

Details

Summary

Adds some ordering options to PhamePost queries. Works on search, PhameHome, BlogHome

Test Plan

Try searching with Order By set to Date Published in application search, get correct order. Check a blog home page, check PhameHome.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

chad retitled this revision from to Allow Phame Posts to be ordered by datePublished.
chad updated this object.
chad edited the test plan for this revision. (Show Details)
chad added a reviewer: epriestley.
epriestley edited edge metadata.

To get this working on PhameHome, it should be sufficient to add ->setOrder('published') to the PhamePostQuery, I think.

src/applications/phame/query/PhamePostQuery.php
126

Hrrm, I'd expect this to break queries, although maybe MySQL is more lenient than I thought.

For consistency, prefer a short alias like post. When providing a table alias, you should also use that alias to refer to columns elsewhere. In buildWhereClauseParts(), edit the queries to be post.id IN ... instead of id IN ..., etc.

131

This key should be 'published', not 'name'. As written, you'd make an API call like phame.post.search(order = name) to order things by publish date.

This revision now requires changes to proceed.Jun 15 2016, 7:08 PM
src/applications/phame/query/PhamePostQuery.php
126

doesn't this need to be the name of the table? If I make it post, it fails.

What's the error you get if you call it post?

(It's normally not the name of the table -- both because it's a little more convenient to use a shorter alias, and because sometimes you'll join the table to itself, which makes it ambiguous/weird if you use the table name.)

e.g., see ManiphestTaskQuery:

protected function getPrimaryTableAlias() {
  return 'task';
}
chad edited edge metadata.
  • Updates

I just deleted it, or should I use that method?

chad edited the test plan for this revision. (Show Details)
chad edited edge metadata.
epriestley edited edge metadata.

You don't need it as long as there are no joins, and there currently aren't.

This revision is now accepted and ready to land.Jun 15 2016, 7:34 PM

(No idea why that test is failing some of the time, let me see if I can figure that out.)

This revision was automatically updated to reflect the committed changes.

I tried to reproduce the issue locally and on the build server without any luck. I'll add some more assertions if it keeps happening to maybe narrow it down.

iiam