-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Fix tag posts list paging #19881
[Reader] Fix tag posts list paging #19881
Conversation
There are other places where we might also be comparing the strings instead of dates (example). Might be worth to investigate them when we can. |
This might solve the inserted items animation issue that made us revert the updated fetched tag posts limit. I'm submitting a PR with that change again since the performance gain was meaningful. You might still see items being moved only the first time it loads if you already had posts for that tag in the local database. |
📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
|
…fetching-new-pages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR, this issue has been happening to several tags and feeds and it looks like you found one of the main root causes! 🙇🏼
I added a few suggestions regarding other date fields and other queries using sorting by date, maybe we want to fix them too.
Just a note: it's not possible to test this specific fix with the "View all responses" from Blogging Prompts after syncing this branch with trunk
, since trunk
already had a fix for the prompts order issue (#19730) that solved it by making the getSortColumnForTag
function use the date_tagged
column (which seems to be normalized in terms of timezone).
@@ -751,7 +751,7 @@ private static String getSortColumnForTag(ReaderTag tag) { | |||
} else if (tag.isTagTopic() || tag.isBookmarked()) { | |||
return "date_tagged"; | |||
} else { | |||
return "date_published"; | |||
return "datetime(date_published)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ So it seems like the issue is that we store this date as a string but it has format like "2024-01-08T14:42:19+00:00", and not all posts have the same timezone, causing the order to be inconsistent since the backend actually treats the field as a date. This is a really nice catch, thanks!
💡 Also, since this is the issue, I think it makes sense to add datetime
around the other date-related cases above (lines 746, 748, and 752), since they would suffer the same problem.
💡 Do you think it also makes sense to use the datetime
function on other queries in this file that use a date as order
clause? (here, here, here, here, and here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, @thomashorta !
💡 Also, since this is the issue, I think it makes sense to add datetime around the other date-related cases above (lines 746, 748, and 752), since they would suffer the same problem.
💡 Do you think it also makes sense to use the datetime function on other queries in this file that use a date as order clause? (here, here, here, here, and here)
I agree 100%, but this also means we'd have to test every single scenario that relies on the logic you've mentioned in this same PR, right? Since this already solves the original tag post list issue, does it make sense to create a separate issue for the other places where we can thoroughly investigate and test the new changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, let's make the datetime
change for the other places in a different PR then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generated by 🚫 Danger |
Fixes #19879
We were sorting the tag related blog posts comparing
date_published
as a string instead of a date. This was causing paging not to work properly.I've replaced
...ORDER BY date_published...
with...ORDER BY datetime(date_published)...
in our query so the posts are sorted as dates correctly.Before
Screen.Recording.2024-01-03.at.8.02.56.PM.mov
After
Screen.Recording.2024-01-03.at.7.09.23.PM.mov
To Test:
Please test this change with different SQLite versions. Also compare the results with web to make sure now we're displaying the same results using the same order.
Another way to test is opening the tag posts list from blogging prompts card:
Regression Notes
Potential unintended areas of impact
datetime(...)
might not available in every version?What I did to test those areas of impact (or what existing automated tests I relied on)
What automated tests I added (or what prevented me from doing so)
--
PR Submission Checklist:
RELEASE-NOTES.txt
if necessary.UI Changes Testing Checklist: