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

Fixes whole campaign not being fetched #97115

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

j6ll
Copy link
Member

@j6ll j6ll commented Dec 5, 2024

Proposed Changes

  • When switching to the "whole campaign" it was not re-fetching data
  • Whole campaign was loading 7 days by default, not the actual campaign dates
  • Switch data to hourly when the campaign is less than a 3 days old
  • Switch hourly labelling to include date, since it could now be multi-day

Testing Instructions

Screen.Recording.2024-12-05.at.13.01.11.mov

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • blaze-dashboard
  • notifications

To test WordPress.com changes, run install-plugin.sh $pluginSlug jamesgill23/fix-whole-campaign-fetching on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented Dec 5, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~6 bytes added 📈 [gzipped])

name             parsed_size           gzip_size
promote-post-i2        +34 B  (+0.0%)       +6 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@j6ll j6ll requested a review from therocket-gr December 5, 2024 13:32
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 5, 2024
@j6ll j6ll requested a review from timur987 December 5, 2024 13:33
@@ -875,7 +879,7 @@ export default function CampaignItemDetails( props: Props ) {
label={ chartSource }
/>
{ getCampaignStatsChart(
campaignStats?.series[ chartSource ] ?? [],
campaignStats?.series[ chartSource ] ?? null,
Copy link
Member Author

@j6ll j6ll Dec 5, 2024

Choose a reason for hiding this comment

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

empty array can be a valid response for no data, so I intend to handle these cases differently and so intentionally passing null here

Copy link
Contributor

@therocket-gr therocket-gr left a comment

Choose a reason for hiding this comment

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

i couldnt test everything as i dont have a lot of active campaigns (in prod or in local)
I tested the refetching of the data when I switch date ranges and did a thorough code review
everything LGTM

@timur987
Copy link
Contributor

timur987 commented Dec 6, 2024

i couldnt test everything as i dont have a lot of active campaigns (in prod or in local)
I tested the refetching of the data when I switch date ranges and did a thorough code review
everything LGTM

Hey @therocket-gr,

just letting you know that I manage having prod data locally with the trick James provided in his earlier PR. Basically, you change the ID of your test campaign to 110111 and run SQL query to populate data copied from production.

Druid has data for that campaign, so you can operate with start_date and end_date values for your local campaign and test short and long campaigns.

The intention of this message is not to ask you to test again (I'm testing it right now) since you've already do CR, but to let you know about an approach how to test similar code changes in the future.

@therocket-gr
Copy link
Contributor

i couldnt test everything as i dont have a lot of active campaigns (in prod or in local)
I tested the refetching of the data when I switch date ranges and did a thorough code review
everything LGTM

Hey @therocket-gr,

just letting you know that I manage having prod data locally with the trick James provided in his earlier PR. Basically, you change the ID of your test campaign to 110111 and run SQL query to populate data copied from production.

Druid has data for that campaign, so you can operate with start_date and end_date values for your local campaign and test short and long campaigns.

The intention of this message is not to ask you to test again (I'm testing it right now) since you've already do CR, but to let you know about an approach how to test similar code changes in the future.

thanks for the extra info :)

@j6ll
Copy link
Member Author

j6ll commented Dec 6, 2024

Yeah, this is a tricky one to test, so whatever you can test plus a code review should be adequate as I provided a demo video to show the behaviour :). The main issue here is that the data is not being re-fetched.

Which was because of this, whole campaign was not calling the same function as the other date options.
Screenshot 2024-12-06 at 10 48 46

Copy link
Contributor

@timur987 timur987 left a comment

Choose a reason for hiding this comment

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

Thanks @j6ll!

The code looks great and works as advertised.

Although I left a comment about a suggestion from VS Code, it's definitely not a blocker to go ahead.

@@ -63,7 +63,7 @@ const CampaignStatsLineChart = ( { data, source, resolution }: GraphProps ) => {

const formatDate = ( date: Date, hourly: boolean ) => {
const options: Intl.DateTimeFormatOptions = hourly
? { hour: 'numeric', minute: 'numeric' }
? { month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' }
: { month: 'short', day: 'numeric' };
return new Intl.DateTimeFormat( locale, options ).format( date );
};
Copy link
Contributor

Choose a reason for hiding this comment

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

VS Code suggests to move formatDate function to useMemo hook callback entirely.

Also, I noticed that useMemo's dependencies can start including locale value.

Here's the patch.txt.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you timur, I've got another PR ready for review very soon. I will move it in that PR and ship this one.

Copy link
Member Author

@j6ll j6ll Dec 6, 2024

Choose a reason for hiding this comment

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

@j6ll j6ll merged commit 26a3b5e into trunk Dec 6, 2024
11 checks passed
@j6ll j6ll deleted the jamesgill23/fix-whole-campaign-fetching branch December 6, 2024 12:51
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 6, 2024
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.

4 participants