wallabag / wallabag

wallabag is a self hostable application for saving web pages: Save and classify articles. Read them later. Freely.
https://wallabag.org
MIT License
10.54k stars 772 forks source link

When I query the data imported from Pocket, the data order is reversed #6251

Open fengqi opened 1 year ago

fengqi commented 1 year ago

Environment

My app/config/parameters.yml is: ``` parameters: database_driver: pdo_mysql database_host: '********' database_port: 3306 database_name: 'wallabag' database_user: 'wallabag' database_password: '********' database_path: '%kernel.project_dir%/data/db/wallabag.sqlite' database_table_prefix: wallabag_ database_socket: null database_charset: utf8mb4 domain_name: 'https://***.example.com' server_name: WallbagPocket mailer_dsn: 'smtp://127.0.0.1' locale: zh secret: ******* twofactor_auth: true twofactor_sender: no-reply@wallabag.org fosuser_registration: true fosuser_confirmation: true fos_oauth_server_access_token_lifetime: 3600 fos_oauth_server_refresh_token_lifetime: 1209600 from_email: no-reply@wallabag.org rss_limit: 50 rabbitmq_host: localhost rabbitmq_port: 5672 rabbitmq_user: guest rabbitmq_password: guest rabbitmq_prefetch_count: 10 redis_scheme: tcp redis_host: 127.0.0.1 redis_port: 6379 redis_path: null redis_password: null sentry_dsn: null ```

What steps will reproduce the bug?

Usually, the data is inserted into the database sequentially, and the id is from small to large. When you need to query positive and negative by time(created), you can use id instead, but I encountered a special situation.

I imported some data from Pocket, and then I found that the display in iOS Client order is reversed.

I checked the query code and found that when $sort == "created" the id is actually used, but the data import order of Pocket is reversed.

So in this case, we can only use createdAt query, not id

mysql> select id, created_at from wallabag_entry order by id desc limit 10;
+-----+---------------------+
| id  | created_at          |
+-----+---------------------+
| 325 | 2023-01-19 18:35:44 |
| 320 | 2014-10-30 19:37:49 |
| 319 | 2014-10-30 19:39:24 |
| 318 | 2014-10-30 19:40:19 |
| 317 | 2014-10-30 19:40:38 |
| 316 | 2014-10-30 19:40:51 |
| 315 | 2014-10-30 19:41:35 |
| 314 | 2014-11-15 15:07:02 |
| 313 | 2014-12-04 21:47:03 |
| 312 | 2015-02-10 16:51:26 |
+-----+---------------------+
10 rows in set (0.00 sec)
nicosomb commented 1 year ago

Hello @fengqi. Thank you for your issue.

If I understand, it's an iOS issue?

fengqi commented 1 year ago

Hello @nicosomb

I think there is a both issue with iOS and the server side,

When iOS call "/api/entries.json?page=1&perPage=50&order=desc", the given data is reversed(sort=create is the default)

When iOS get the data from the server, it uses the id to sort, even if the data given by the server is correct or not, the display is also reversed.