Skip to content

Commit

Permalink
Merge pull request #19949 from wordpress-mobile/issue/19897-fix-reade…
Browse files Browse the repository at this point in the history
…rposttable-sorting-date-as-string

[Reader IA] Fix ReaderPostTable sorting date as string
  • Loading branch information
RenanLukas authored Jan 16, 2024
2 parents 3358440 + 6ecdb71 commit 0c65f60
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,14 @@ 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)});
}

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)});
}

Expand Down Expand Up @@ -743,13 +743,13 @@ 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";
return "datetime(date_published)";
} 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)";
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0c65f60

Please sign in to comment.