News: Articles should be ordered by pubdate when saving them to the database

Created on 10 Nov 2016  Â·  13Comments  Â·  Source: nextcloud/news

Explain the Problem

The list of entries in a group is not sortable by time. It's possible to sort an individual news feed (e.g. newest on top), but as soon as I click on the group to display all feeds in that group, the order gets mixed up.

Steps to Reproduce

  1. Sort all feeds inside a group to be 'newest first'
  2. View the parent group and notice that the order is mixed up instead of newest first for all feeds inside that group

System Information

  • News app version: 9.0.4
  • Nextcloud version: 10.0.1
  • PHP version: 7.0.12
  • Database and version: mysql 10.1.18
  • Browser and version: Tried with several browsers
  • Distribution and version: ArchLinuxARM


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

bug help wanted junior job starter issue

All 13 comments

Also works as expected. Articles are sorted by date added and not by their given published date because there are issues with pagination.

The issue is only present the first time you use the app

https://github.com/owncloud/news/issues/836

I can not confirm that it's working as expected. The sorting is also mixed
up with new articles (after the initial import), not only imported ones.

On Thu, Nov 10, 2016 at 9:35 AM Bernhard Posselt [email protected]
wrote:

Also works as expected. Articles are sorted by date added and not by their
given published date because there are issues with pagination.

The issue is only present the first time you use the app

owncloud/news#836 https://github.com/owncloud/news/issues/836

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/nextcloud/news/issues/51#issuecomment-259631215, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABUtN0szpJ_JT8CGqDKmYLNQS7rgjQYjks5q8tdSgaJpZM4KuVGG
.

They should be in order when they were added. Ordering is done by id which is an auto increment when things are added. So there might be slight differences depending on if the feed reports a wrong date or when articles are added faster than in a different feed.

Again, works as expected ;)

Please read up on the linked issues if you still disagree

TL;DR: Changes required for fixing this issue are basically the following:

  • Use 128bit Integers (we lack the hardware) to do this on a database level
  • Get rid of autopaging which will significantly slow down the web interface since everything has to be loaded when changing feeds rather than loading it on demand

I will continue to test the behavior in the next couple of days, but the
sorting keeps getting mixed up by several hours or even days in some cases:

11-11-2016 11-29-46

On Thu, Nov 10, 2016 at 1:34 PM Bernhard Posselt [email protected]
wrote:

TL;DR: Changes required for fixing this issue are basically the following:

  • Use 128bit Integers (we lack the hardware) to do this on a database
    level
  • Get rid of autopaging which will significantly slow down the web
    interface

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/nextcloud/news/issues/51#issuecomment-259679123, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABUtNzN0uiPgxpPl0MJps3YYwSZNPPTEks5q8w9wgaJpZM4KuVGG
.

Would be interesting if you could provide example feeds. The image was not appended btw

Reason is that google does not publish the articles in order when they were released. A sort by pubdate should work before the loop is being run here https://github.com/nextcloud/news/blob/master/lib/Service/FeedService.php#L238

FYI this wont fix the "group" ordering but ordering them by pubdate is probably a good idea when adding new feeds

The reverse loop can be dropped in favor of a foreach loop.

http://php.net/manual/en/function.usort.php can be used to compare items by their pubdate, probably similar to this:

usort($items, function ($a, $b) { 
    return ($a->getPubDate() < $b->getPubDate()) ? -1 : 1; 
}); 

@BernhardPosselt Any updates on this matter? :blush:

@Peque yeah, I stopped maintaing the app.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

severin-lemaignan picture severin-lemaignan  Â·  8Comments

jas4711 picture jas4711  Â·  6Comments

anoymouserver picture anoymouserver  Â·  4Comments

criwe picture criwe  Â·  7Comments

David-Development picture David-Development  Â·  3Comments