Skip to content

site: fix minor build time bugs #4569

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

Merged
merged 1 commit into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/src/components/TemplateStats/TemplateStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const TemplateStats: FC<TemplateStatsProps> = ({
<span className={styles.statsLabel}>{Language.buildTimeLabel}</span>

<span className={styles.statsValue}>
{formatTemplateBuildTime(template.active_user_count)}{" "}
{formatTemplateBuildTime(template.average_build_time_ms)}{" "}
</span>
</div>
<div className={styles.statsDivider} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ const estimateFinish = (
templateAverage *= 1.2

const realPercentage = dayjs().diff(startedAt) / templateAverage
// Showing a full bar is frustrating.
const displayPercentage = Math.min(realPercentage, 0.95)

if (realPercentage > 1) {
return [displayPercentage, "Any moment now..."]
// Showing a full bar is frustrating.
if (realPercentage > 0.95) {
return [0.95, "Any moment now..."]
}

return [
displayPercentage,
`${dayjs
.duration((1 - realPercentage) * templateAverage)
.humanize()} remaining...`,
realPercentage,
`~${Math.ceil(
dayjs.duration((1 - realPercentage) * templateAverage).asSeconds(),
)} seconds remaining...`,
]
}

Expand Down
2 changes: 1 addition & 1 deletion site/src/util/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const formatTemplateActiveDevelopers = (num?: number): string => {
export const formatTemplateBuildTime = (buildTimeMs: number): string => {
return buildTimeMs < 0
? "Unknown"
: dayjs.duration(buildTimeMs, "milliseconds").humanize()
: `${Math.round(dayjs.duration(buildTimeMs, "milliseconds").asSeconds())}s`
}