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: Pass in interval to aggregate functions, dynamic copy updates for intervals #3425

Conversation

ajay-sentry
Copy link
Contributor

@ajay-sentry ajay-sentry commented Oct 22, 2024

Description

This PR does a small feature add passing in the historicalTrend parameter to the "interval" filter for both the testResultsAggregates and flakeAggregates queries, and does some minor dynamic copy updates taking into account that filter if it exists.

I chose not to use this thing because it was hard coded to have the capitals at the beginning of the label and I needed something a little more precise for my use case.

Closes codecov/engineering-team#2691

export const MeasurementTimeOptions = [
{ label: 'Last 30 days', value: MEASUREMENT_INTERVAL.INTERVAL_30_DAY },
{ label: 'Last 7 days', value: MEASUREMENT_INTERVAL.INTERVAL_7_DAY },
{ label: 'Last day', value: MEASUREMENT_INTERVAL.INTERVAL_1_DAY },
] as const

Screenshots

Screenshot 2024-10-22 at 1 55 42 PM
Screenshot 2024-10-22 at 1 55 56 PM

Link to Sample Entry

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@@ -4,7 +4,7 @@ export const MEASUREMENT_INTERVAL = {
INTERVAL_1_DAY: 'INTERVAL_1_DAY',
} as const

export type MEASUREMENT_INTERVAL_TYPE = keyof typeof MEASUREMENT_INTERVAL
export type MeasurementInterval = keyof typeof MEASUREMENT_INTERVAL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just a lot cleaner looking to me, changed all the other instances to use this as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Not sure what pattern we go for elsewhere but looks like at least in this file we sometimes have the enum options have a pluralized name to help distinguish it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is something we'll need to hash out as a team and make a norm around. I see all sorts of patterns throughout the codebase but I think having a shared consts file or directory with labeled files for each const makes the most sense to me

@@ -56,12 +57,6 @@ const query = `
}
`

export enum MeasurementInterval {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the enum here so we could have a single source of truth

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Oct 22, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
88d2ec9 Tue, 22 Oct 2024 21:03:38 GMT Expired Expired
65b525f Tue, 22 Oct 2024 22:04:17 GMT Expired Expired
0fc4a00 Thu, 24 Oct 2024 18:46:50 GMT Expired Expired
5ec3494 Thu, 24 Oct 2024 18:53:54 GMT Expired Expired
2fbc6ac Thu, 24 Oct 2024 20:35:34 GMT Expired Expired
2fbc6ac Thu, 24 Oct 2024 20:36:50 GMT Cloud Enterprise

Copy link

codecov bot commented Oct 22, 2024

Bundle Report

Changes will decrease total bundle size by 6.14MB (-35.6%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.52MB 348 bytes (0.01%) ⬆️
gazebo-production-system-esm 5.58MB 191 bytes (0.0%) ⬆️
gazebo-production-array-push (removed) 6.14MB (-100.0%) ⬇️

@codecov-staging
Copy link

codecov-staging bot commented Oct 22, 2024

Bundle Report

Changes will decrease total bundle size by 6.14MB (-35.6%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system 5.52MB 348 bytes (0.01%) ⬆️
gazebo-staging-system-esm 5.58MB 191 bytes (0.0%) ⬆️
gazebo-staging-array-push (removed) 6.14MB (-100.0%) ⬇️

@codecov-notifications
Copy link

codecov-notifications bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           tests-analytics-v2    #3425   +/-   ##
===================================================
  Coverage               99.07%   99.07%           
===================================================
  Files                     816      816           
  Lines                   14518    14526    +8     
  Branches                 4023     4034   +11     
===================================================
+ Hits                    14384    14392    +8     
  Misses                    125      125           
  Partials                    9        9           
Files with missing lines Coverage Δ
...ledTestsPage/FailedTestsTable/FailedTestsTable.tsx 96.03% <100.00%> (+0.07%) ⬆️
.../FailedTestsPage/MetricsSection/MetricsSection.tsx 91.02% <100.00%> (+1.17%) ⬆️
...ailedTestsPage/SelectorSection/SelectorSection.tsx 95.74% <ø> (ø)
...ge/hooks/useFlakeAggregates/useFlakeAggregates.tsx 100.00% <ø> (ø)
.../useInfiniteTestResults/useInfiniteTestResults.tsx 100.00% <ø> (ø)
...TestResultsAggregates/useTestResultsAggregates.tsx 100.00% <100.00%> (ø)
src/pages/RepoPage/shared/constants.ts 100.00% <ø> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.77% <100.00%> (+<0.01%) ⬆️
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (ø)
UI 99.06% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8fbf0f...2fbc6ac. Read the comment docs.

Copy link

codecov-public-qa bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.07%. Comparing base (f8fbf0f) to head (2fbc6ac).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           tests-analytics-v2    #3425   +/-   ##
===================================================
  Coverage               99.07%   99.07%           
===================================================
  Files                     816      816           
  Lines                   14518    14526    +8     
  Branches                 4023     4034   +11     
===================================================
+ Hits                    14384    14392    +8     
  Misses                    125      125           
  Partials                    9        9           
Files Coverage Δ
...ledTestsPage/FailedTestsTable/FailedTestsTable.tsx 96.03% <100.00%> (+0.07%) ⬆️
.../FailedTestsPage/MetricsSection/MetricsSection.tsx 91.02% <100.00%> (+1.17%) ⬆️
...ailedTestsPage/SelectorSection/SelectorSection.tsx 95.74% <ø> (ø)
...ge/hooks/useFlakeAggregates/useFlakeAggregates.tsx 100.00% <ø> (ø)
.../useInfiniteTestResults/useInfiniteTestResults.tsx 100.00% <ø> (ø)
...TestResultsAggregates/useTestResultsAggregates.tsx 100.00% <100.00%> (ø)
src/pages/RepoPage/shared/constants.ts 100.00% <ø> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.77% <100.00%> (+<0.01%) ⬆️
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (ø)
UI 99.06% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8fbf0f...2fbc6ac. Read the comment docs.

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.07%. Comparing base (f8fbf0f) to head (5ec3494).

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##           tests-analytics-v2    #3425   +/-   ##
===================================================
  Coverage               99.07%   99.07%           
===================================================
  Files                     816      816           
  Lines                   14518    14527    +9     
  Branches                 4030     4034    +4     
===================================================
+ Hits                    14384    14393    +9     
  Misses                    125      125           
  Partials                    9        9           
Files with missing lines Coverage Δ
...ledTestsPage/FailedTestsTable/FailedTestsTable.tsx 96.03% <100.00%> (+0.07%) ⬆️
.../FailedTestsPage/MetricsSection/MetricsSection.tsx 91.13% <100.00%> (+1.28%) ⬆️
...ailedTestsPage/SelectorSection/SelectorSection.tsx 95.74% <ø> (ø)
...ge/hooks/useFlakeAggregates/useFlakeAggregates.tsx 100.00% <ø> (ø)
.../useInfiniteTestResults/useInfiniteTestResults.tsx 100.00% <ø> (ø)
...TestResultsAggregates/useTestResultsAggregates.tsx 100.00% <100.00%> (ø)
src/pages/RepoPage/shared/constants.ts 100.00% <ø> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.77% <100.00%> (+<0.01%) ⬆️
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (ø)
UI 99.06% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8fbf0f...5ec3494. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.07%. Comparing base (f8fbf0f) to head (2fbc6ac).
Report is 1 commits behind head on tests-analytics-v2.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           tests-analytics-v2    #3425   +/-   ##
===================================================
  Coverage               99.07%   99.07%           
===================================================
  Files                     816      816           
  Lines                   14518    14526    +8     
  Branches                 4023     4034   +11     
===================================================
+ Hits                    14384    14392    +8     
  Misses                    125      125           
  Partials                    9        9           
Files with missing lines Coverage Δ
...ledTestsPage/FailedTestsTable/FailedTestsTable.tsx 96.03% <100.00%> (+0.07%) ⬆️
.../FailedTestsPage/MetricsSection/MetricsSection.tsx 91.02% <100.00%> (+1.17%) ⬆️
...ailedTestsPage/SelectorSection/SelectorSection.tsx 95.74% <ø> (ø)
...ge/hooks/useFlakeAggregates/useFlakeAggregates.tsx 100.00% <ø> (ø)
.../useInfiniteTestResults/useInfiniteTestResults.tsx 100.00% <ø> (ø)
...TestResultsAggregates/useTestResultsAggregates.tsx 100.00% <100.00%> (ø)
src/pages/RepoPage/shared/constants.ts 100.00% <ø> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.77% <100.00%> (+<0.01%) ⬆️
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (ø)
UI 99.06% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8fbf0f...2fbc6ac. Read the comment docs.

@@ -91,7 +91,7 @@ describe('useFlakeAggregates', () => {
const { result } = renderHook(
() =>
useFlakeAggregates({
interval: MeasurementInterval.INTERVAL_1_DAY,
interval: 'INTERVAL_1_DAY',
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmmm why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was so we could have a single source of truth/type coming from that shared consts file

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you import it from there maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The type is persistent so there's no import required :O
Or what did you have in mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made a change in 0fc4a00

const columns = useMemo(
() =>
getColumns({
hideFlakeRate: !!hideFlakeRate,
Copy link
Contributor

Choose a reason for hiding this comment

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

the !! seems unnecessary. This could just be hideFlakeRate, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I didn't really think about it but yep the !! is unnecessary

Copy link
Contributor

@suejung-sentry suejung-sentry left a comment

Choose a reason for hiding this comment

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

looks good to me!

@@ -4,7 +4,7 @@ export const MEASUREMENT_INTERVAL = {
INTERVAL_1_DAY: 'INTERVAL_1_DAY',
} as const

export type MEASUREMENT_INTERVAL_TYPE = keyof typeof MEASUREMENT_INTERVAL
export type MeasurementInterval = keyof typeof MEASUREMENT_INTERVAL
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Not sure what pattern we go for elsewhere but looks like at least in this file we sometimes have the enum options have a pluralized name to help distinguish it

@@ -83,6 +86,9 @@ const TotalTestsRunTimeCard = ({
<PercentBadge value={totalDurationPercentChange} />
) : null}
</MetricCard.Content>
<MetricCard.Description>
The cumulative CI time spent running tests over the last {intervalCopy}
Copy link
Contributor

Choose a reason for hiding this comment

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

period at the end here to be consistent with the other descriptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! Will fix

case 'INTERVAL_7_DAY':
return '7 days'
case 'INTERVAL_30_DAY':
return '30 days'
Copy link
Contributor

@calvin-codecov calvin-codecov Oct 24, 2024

Choose a reason for hiding this comment

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

nit: we could remove this line since these last two return the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

trueee, I prefer the explicit nature though personally, in the event someone comes back and changes the default case for whatever reason

Copy link
Contributor

Choose a reason for hiding this comment

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

oh i mean just line 333 but leave 332

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohhhh big facts, I like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 2fbc6ac

@ajay-sentry ajay-sentry merged commit 0ccd8b0 into tests-analytics-v2 Oct 24, 2024
58 of 59 checks passed
@ajay-sentry ajay-sentry deleted the Ajay/pass-in-measurement-interval-and-dynamic-copy branch October 24, 2024 20:52
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.

5 participants