Load newest blogging prompts#25566
Open
crazytonyli wants to merge 2 commits into
Open
Conversation
Add order=desc to the request and pin force_year to the current year (using the Gregorian calendar) so the server always returns prompts stamped with the right year, including around year boundaries where fetchListPrompts spans late December into early January.
Collaborator
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 32256 | |
| Version | PR #25566 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 1e9bf80 | |
| Installation URL | 40mes9m6e39hg |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 32256 | |
| Version | PR #25566 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 1e9bf80 | |
| Installation URL | 52js8vq3pmap0 |
jkmassel
approved these changes
May 21, 2026
Contributor
jkmassel
left a comment
There was a problem hiding this comment.
A few suggestions, but then this is good to go
| let date = try passedDate() | ||
| XCTAssertEqual("2022-01-02", try passedDate()) | ||
| // `force_year` is now always the current year, so the reconstructed date carries it. | ||
| let currentYear = Calendar(identifier: .gregorian).component(.year, from: Date()) |
Contributor
There was a problem hiding this comment.
Will this be flaky in early January?
| let currentYear = Calendar(identifier: .gregorian).component(.year, from: Date()) | ||
| XCTAssertEqual("\(currentYear)-01-02", try passedDate()) | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
Should we have this test?
Suggested change
| func test_fetchPrompts_alwaysPassesDescendingOrder() throws { | |
| service.fetchPrompts(success: { _ in }, failure: { _ in }) | |
| XCTAssertEqual(try passedParameter("order") as? String, "desc") | |
| } |
| if let forceYear = forceYear ?? fromDate?.dateAndTimeComponents().year { | ||
| params["force_year"] = forceYear | ||
| } | ||
| params["force_year"] = forceYear ?? Calendar(identifier: .gregorian).component(.year, from: Date()) |
Contributor
There was a problem hiding this comment.
Might be worth explaining why we do it this way?
Suggested change
| params["force_year"] = forceYear ?? Calendar(identifier: .gregorian).component(.year, from: Date()) | |
| // The server expects a Gregorian year, so use that Calendar rather than the user's | |
| params["force_year"] = forceYear ?? Calendar(identifier: .gregorian).component(.year, from: Date()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Fixes https://linear.app/a8c/issue/CMM-2068.
Align the API call with calypso
The first commit only contains code format changes. The second commit is the real change.