From a7a7730dbeca84a1e931c2e602bd0dc37ab7f059 Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:38:12 -0300 Subject: [PATCH 1/8] Add datetime function to liked feed local database sorting These entities were being sorted by date_liked as a string, and it was working because they are being inserted with the same timezone. This solution is weak, because if the timezone ever changes among entities the sorting will stop working. Using datetime function solves this issue. --- .../java/org/wordpress/android/datasets/ReaderPostTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index c5b485d7ee3b..d652ba3de2ee 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -743,7 +743,7 @@ public static String getGapMarkerDateForTag(ReaderTag tag) { */ private static String getSortColumnForTag(ReaderTag tag) { if (tag.isPostsILike()) { - return "date_liked"; + return "datetime(date_liked)"; } else if (tag.isFollowedSites()) { return "date_published"; } else if (tag.tagType == ReaderTagType.SEARCH) { From ee1744c27ea4eef348197d2083d1160e7f26aec2 Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Mon, 15 Jan 2024 19:00:44 -0300 Subject: [PATCH 2/8] Add datetime function to subscriptions feed local database sorting These entities were being sorted by date_published as a string, and it works as long as they are inserted with the same timezone. This solution is weak, because if the timezone ever changes among entities the sorting will stop working. Using datetime function solves this issue. --- .../java/org/wordpress/android/datasets/ReaderPostTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index d652ba3de2ee..2c18a8beb215 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -745,7 +745,7 @@ private static String getSortColumnForTag(ReaderTag tag) { if (tag.isPostsILike()) { return "datetime(date_liked)"; } else if (tag.isFollowedSites()) { - return "date_published"; + return "datetime(date_published)"; } else if (tag.tagType == ReaderTagType.SEARCH) { return "score"; } else if (tag.isTagTopic() || tag.isBookmarked()) { From 6585b196946c03f66697a5a266cb4b70e6268408 Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:12:55 -0300 Subject: [PATCH 3/8] Add datetime function to Saved feed local database sorting These entities were being sorted by date_tagged as a string, and it works as long as they are inserted with the same timezone. This solution is weak, because if the timezone ever changes among entities the sorting will stop working. Using datetime function solves this issue. --- .../java/org/wordpress/android/datasets/ReaderPostTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index 2c18a8beb215..7f5c63bb4fbc 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -749,7 +749,7 @@ private static String getSortColumnForTag(ReaderTag tag) { } else if (tag.tagType == ReaderTagType.SEARCH) { return "score"; } else if (tag.isTagTopic() || tag.isBookmarked()) { - return "date_tagged"; + return "datetime(date_tagged)"; } else { return "datetime(date_published)"; } From 9571c5993d56e81cebfcb94260e2635c6e2f1bf5 Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:40:04 -0300 Subject: [PATCH 4/8] Add datetime function to getOldestPubDateInBlog sorting --- .../java/org/wordpress/android/datasets/ReaderPostTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index 7f5c63bb4fbc..7f0e3df6b9a2 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -658,7 +658,7 @@ public static String getOldestDateWithTag(final ReaderTag tag) { public static String getOldestPubDateInBlog(long blogId) { String sql = "SELECT date_published FROM tbl_posts" + " WHERE blog_id=? AND tag_name='' AND tag_type=0" - + " ORDER BY date_published LIMIT 1"; + + " ORDER BY datetime(date_published) LIMIT 1"; return SqlUtils.stringForQuery(ReaderDatabase.getReadableDb(), sql, new String[]{Long.toString(blogId)}); } From 417de073860e44d0cff220265ab6e494efe5ac14 Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:41:11 -0300 Subject: [PATCH 5/8] Add datetime function to getOldestPubDateInFeed sorting --- .../java/org/wordpress/android/datasets/ReaderPostTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index 7f0e3df6b9a2..bf0ab39f10e3 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -665,7 +665,7 @@ public static String getOldestPubDateInBlog(long blogId) { public static String getOldestPubDateInFeed(long feedId) { String sql = "SELECT date_published FROM tbl_posts" + " WHERE feed_id=? AND tag_name='' AND tag_type=0" - + " ORDER BY date_published LIMIT 1"; + + " ORDER BY datetime(date_published) LIMIT 1"; return SqlUtils.stringForQuery(ReaderDatabase.getReadableDb(), sql, new String[]{Long.toString(feedId)}); } From 10b9f806ed9b5b89637ad0556f8c6c96a5c53a4a Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:42:27 -0300 Subject: [PATCH 6/8] Add datetime function to getPostsInBlog sorting --- .../java/org/wordpress/android/datasets/ReaderPostTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index bf0ab39f10e3..4d2ab0fab2bb 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -982,7 +982,7 @@ public static ReaderPostList getPostsInBlog(long blogId, int maxPosts, boolean e String columns = (excludeTextColumn ? COLUMN_NAMES_NO_TEXT : "*"); String sql = "SELECT " + columns + " FROM tbl_posts WHERE blog_id=? AND tag_name='' AND tag_type=0" - + " ORDER BY date_published DESC"; + + " ORDER BY datetime(date_published) DESC"; if (maxPosts > 0) { sql += " LIMIT " + maxPosts; From bbe0fe93397cb8c6e000bf5a25b5a608546866ff Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:43:34 -0300 Subject: [PATCH 7/8] Add datetime function to getPostsInFeed sorting --- .../java/org/wordpress/android/datasets/ReaderPostTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index 4d2ab0fab2bb..390d6796ced8 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -1020,7 +1020,7 @@ public static ReaderPostList getPostsInFeed(long feedId, int maxPosts, boolean e String columns = (excludeTextColumn ? COLUMN_NAMES_NO_TEXT : "*"); String sql = "SELECT " + columns + " FROM tbl_posts WHERE feed_id=? AND tag_name='' AND tag_type=0" - + " ORDER BY date_published DESC"; + + " ORDER BY datetime(date_published) DESC"; if (maxPosts > 0) { sql += " LIMIT " + maxPosts; From c14d45712b44e761732d2acd7a44351126c66b78 Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Mon, 15 Jan 2024 20:44:26 -0300 Subject: [PATCH 8/8] Add datetime function to getBlogIdPostIdsInBlog sorting --- .../java/org/wordpress/android/datasets/ReaderPostTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index 390d6796ced8..6235ba23151c 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -1097,7 +1097,7 @@ private static ReaderBlogIdPostIdList getBlogIdPostIds(@NonNull String sql, @Non */ public static ReaderBlogIdPostIdList getBlogIdPostIdsInBlog(long blogId, int maxPosts) { String sql = "SELECT post_id FROM tbl_posts WHERE blog_id=? AND tag_name='' AND tag_type=0" - + " ORDER BY date_published DESC"; + + " ORDER BY datetime(date_published) DESC"; if (maxPosts > 0) { sql += " LIMIT " + maxPosts;