The aggregator module displays a page of 'sources' ( http://www.thomashousehold.net/aggregator/sources )but the sources are in the order they were entered into the system. Wouldn't it make sense to add an 'ORDER BY' clause and display in alphabetical order by feed title? I'd work on this myself but I'm still getting familiar with all the APIs and patching procedures, etc.

Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

Version: 4.6.3 » 4.7.0-beta2

It still happens in 4.7 beta2, I was about to report this issue and found this.

This in fact looks like a bug to me. In the function aggregator_page_sources() a query (let's call it the outer query) is made to scan the {aggregator_feed} table and then an inner query scans the items in timestamp order. So there are two different queries here.

However, the first one (the outer query) does a JOIN with the items table to group the results by last item timestamp. This is how it looks:

SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last
  FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid
  GROUP BY f.fid, f.title, f.description, f.image

Though 'last' is not used anywhere! ...I guess the intention was to order the sources page by last updated source first, so the query should probably look like this:

SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last
  FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid
  GROUP BY f.fid, f.title, f.description, f.image
  ORDER BY 5 DESC, f.title   --- Only change is this Order By clausule ;-)

Note 5 refers to the 5th column specified in the query, which is "MAX(i.timestamp) AS last". I have also added the title, so feeds updated at the same time (more exactly not updated ;-) get ordered by title.

markus_petrux’s picture

Version: 4.7.0-beta2 » x.y.z
Status: Active » Needs review
FileSize
871 bytes

I'm attaching the patch.

markus_petrux’s picture

Status: Needs review » Reviewed & tested by the community

Just a tiny patch, that changes the order in the sources pages to make a little more sense, IMO.

Cvbge’s picture

Status: Reviewed & tested by the community » Needs work

Any reason you use ORDER BY 5 and not ORDER BY last? I'd prefer the later.

markus_petrux’s picture

Oh, I guess this is no problem if it's supported by the underlying SQL engine, which I'm not sure.

I just get used to use numbers when referencing columns that use functions, because I had problems in the past (about 10y ago though, using DB2 under MVS).

markus_petrux’s picture

FileSize
874 bytes

Ok, here we go. I just checked with 'last' and worked on MySQL 4.1 so... please, see attached patch.

Cheers

markus_petrux’s picture

Status: Needs work » Reviewed & tested by the community
Tobias Maier’s picture

Status: Reviewed & tested by the community » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)