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

feat: health trend insight #8335

Merged
merged 7 commits into from
Oct 2, 2024
Merged

feat: health trend insight #8335

merged 7 commits into from
Oct 2, 2024

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Oct 2, 2024

About the changes

Showing project health trend message for pro and enterprise customers. Currently it mimicks ios health app with a message how hour average health trend changes between last 4 weeks and previous 4 weeks.
Screenshot 2024-10-02 at 12 26 28

We can add more info e.g. you're doing great job at keeping your project healthy etc. Looking forward to suggestions. the original version only states the facts without telling what's good or bad.

Important files

Discussion points

Copy link

vercel bot commented Oct 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 2, 2024 11:44am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Oct 2, 2024 11:44am

Copy link
Contributor

github-actions bot commented Oct 2, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Comment on lines +140 to +141
{activeProjectStage === 'onboarded' &&
personalDashboardProjectDetails ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

question: can you have an active project stage without personaldashboardprojectdetails? is this redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, but the orval type doesn't allow me to make this state more explicit so I ended up adding two expressions in here

Comment on lines 52 to 69
let trend: HeathTrend = 'unknown';
if (
insights.avgHealthCurrentWindow !== null &&
insights.avgHealthPastWindow !== null
) {
if (insights.avgHealthCurrentWindow > insights.avgHealthPastWindow) {
trend = 'improved';
} else if (
insights.avgHealthCurrentWindow < insights.avgHealthPastWindow
) {
trend = 'declined';
} else if (
insights.avgHealthPastWindow === insights.avgHealthCurrentWindow
) {
trend = 'consistent';
}
}
return trend;
Copy link
Contributor

Choose a reason for hiding this comment

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

we could do an early return here by checking if they're both null and just return the string directly. would decrease nesting by one level and remove the mutable variable. Your choice, though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100%. Fixing

Comment on lines 84 to 127

{projectHealthTrend === 'unknown' ? (
<ConnectedSdkProject project={project} />
) : null}
{projectHealthTrend === 'improved' ? (
<Typography>
On average, your project health went up from{' '}
<PercentageScore>
{insights.avgHealthPastWindow}%
</PercentageScore>{' '}
to{' '}
<PercentageScore>
{insights.avgHealthCurrentWindow}%
</PercentageScore>{' '}
during the last 4 weeks.
</Typography>
) : null}
{projectHealthTrend === 'declined' ? (
<Typography>
On average, your project health went down from{' '}
<PercentageScore>
{insights.avgHealthPastWindow}%
</PercentageScore>{' '}
to{' '}
<PercentageScore>
{insights.avgHealthCurrentWindow}%
</PercentageScore>{' '}
during the last 4 weeks.
</Typography>
) : null}
{projectHealthTrend === 'consistent' ? (
<Typography>
On average, your project health has remained at{' '}
<PercentageScore>
{insights.avgHealthCurrentWindow}%
</PercentageScore>{' '}
during the last 4 weeks.
</Typography>
) : null}
{projectHealthTrend !== 'unknown' ? (
<Link to={`/projects/${project}/insights`}>
View more insights
</Link>
) : null}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd maybe consider extracting this into a variable above instead of a series of ternaries. Just to avoid any future issues 🤷🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored to a separate component with early returns

@kwasniew kwasniew merged commit b975919 into main Oct 2, 2024
11 checks passed
@kwasniew kwasniew deleted the health-trend-insight branch October 2, 2024 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants