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

Fix: Feature usage chart pagination #1013

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

jcscottiii
Copy link
Collaborator

@jcscottiii jcscottiii commented Dec 27, 2024

Background:

When backfilling usage data, the feature usage chart displayed only a few data points, not the complete set. Network inspection revealed that multiple pages of data were successfully retrieved.

Repro:

  1. Navigate to: https://website-webstatus-dev.corp.goog/features/flexbox?showUsageChart
  2. Examine the usage chart. You will see the oldest page of results are only shown. Not all of the points. But if you examine the network tab in DevTools, you will see multiple calls were made.

Solution:

This change aligns the feature usage chart pagination with the feature support chart's implementation:

async _fetchFeatureSupportData(
apiClient: APIClient,
featureId: string,
startDate: Date,
endDate: Date,
) {
if (typeof apiClient !== 'object') return;
this.featureSupportChartDataObj = this.createFeatureSupportDataFromMap();
const channel = STABLE_CHANNEL;
const promises = ALL_BROWSERS.map(async browser => {
for await (const page of apiClient.getFeatureStatsByBrowserAndChannel(
featureId,
browser,
channel,
startDate,
endDate,
)) {
// Append the new data to existing data
const existingData =
this.featureSupport.get(featureSupportKey(browser, channel)) || [];
this.featureSupport.set(featureSupportKey(browser, channel), [
...existingData,
...page,
]);
this.featureSupportChartDataObj =
this.createFeatureSupportDataFromMap();
}
});

Testing:

Comprehensive unit tests will be included with the refactor outlined in #964.

To validate the pagination logic, this commit increases the number of data points displayed to over 100, enabling testing through Playwright. To optimize Playwright test performance, the initial data load specifically filters for the feature used in the feature page test, mitigating delays associated with loading excessive fake data.

Other changes

  • Add more logging to the fake data script

**Background:**

When backfilling usage data, the feature usage chart displayed only a few data points, not the complete set.  Network inspection revealed that multiple pages of data were successfully retrieved.

**Repro:**

1. Navigate to: https://website-webstatus-dev.corp.goog/features/flexbox?showUsageChart

**Solution:**

This change aligns the feature usage chart pagination with the feature support chart's implementation: https://github.com/GoogleChrome/webstatus.dev/blob/b84a9ac02c2455dd6e5043615fc2a084f6980a46/frontend/src/static/js/components/webstatus-feature-page.ts#L621-L650

**Testing:**

Comprehensive unit tests will be included with the refactor outlined in #964.

To validate the pagination logic, this commit increases the number of data points displayed to over 100, enabling testing through Playwright. To optimize Playwright test performance, the initial data load specifically filters for the feature used in the feature page test, mitigating delays associated with loading excessive fake data.
Copy link
Collaborator

@DanielRyanSmith DanielRyanSmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this James!

@jcscottiii jcscottiii added this pull request to the merge queue Dec 30, 2024
Merged via the queue into main with commit 27becb2 Dec 30, 2024
6 checks passed
@jcscottiii jcscottiii deleted the jcscottiii/fix-feature-usage-pagination branch December 30, 2024 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants