-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
{activeProjectStage === 'onboarded' && | ||
personalDashboardProjectDetails ? ( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%. Fixing
|
||
{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} |
There was a problem hiding this comment.
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 🤷🏼
There was a problem hiding this comment.
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
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.
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