CMM-1202 create the stats country endpoint#1131
Conversation
|
@jkmassel I added the remaining stuff to this endpoint:
|
| /// - `Some(false)` (summarize=0, default): Response contains `days` field with a per-day | ||
| /// breakdown of country views, where each day is keyed by its date string. The `summary` | ||
| /// field will be absent. | ||
| #[uniffi(default = Some(false))] |
There was a problem hiding this comment.
We should match the endpoints from the last PR – if we think this should be true by default we should have it be default=true and remove the optionality.
4aa8913 to
9208e76
Compare
| } | ||
|
|
||
| #[test] | ||
| fn test_stats_country_views_response_deserialization_summary_01() { |
There was a problem hiding this comment.
Does this need to be its own test?
It seems to be mostly covered by the test above – should we add more parameters to it?
There was a problem hiding this comment.
There's a small difference between these tests. The above one is a lightweight sanity check test for general purposes (parameterised), while this one is more about checking the detailed values. Si, it's not only checking the deserialisation, but checking that the expected values are present.
Hence, I think that both tests add value in their way. Plus, I think that having extra tests is harmless.
Does it make sense?
There was a problem hiding this comment.
I agree it's not hurting anything, so I'm fine to leave it :)
Summary
stats/country-viewsendpoint for WordPress.com REST API v1.1Changes
New files:
wp_api/src/wp_com/stats_country_views.rs- Type definitions and parameterswp_api/src/wp_com/endpoint/stats_country_views_endpoint.rs- Endpoint implementationwp_api/tests/wpcom/stats_country_views/*.json- Test fixtures for parameterized testsTypes added:
StatsCountryViewsPeriod- Period enum (day, week, month, year)StatsCountryViewsParams- Query parameters (period, date, start_date, max, num, days, locale, summarize)StatsCountryViewsResponse- Response withsummaryordaysdepending onsummarizeparameterStatsCountryInfo- Country metadata (flag icons, country name, map region)StatsCountryView- Individual country view entry (location, views, country_code)Response modes:
summarize=0(default): Returnsdaysfield with per-day breakdown keyed by datesummarize=1: Returnssummaryfield with aggregated country viewsTest plan
cargo fmt,cargo clippy)