Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reader IA] Fix ReaderPostTable sorting date as string #19949

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
Loading