Skip to content

Commit de5ba47

Browse files
authored
site: minor build stats fixes (#4569)
- Correct variable used in the template stats summary - Don't use dayjs.humanize (it thinks 30 seconds is "a few seconds")
1 parent e456799 commit de5ba47

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

site/src/components/TemplateStats/TemplateStats.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const TemplateStats: FC<TemplateStatsProps> = ({
4646
<span className={styles.statsLabel}>{Language.buildTimeLabel}</span>
4747

4848
<span className={styles.statsValue}>
49-
{formatTemplateBuildTime(template.active_user_count)}{" "}
49+
{formatTemplateBuildTime(template.average_build_time_ms)}{" "}
5050
</span>
5151
</div>
5252
<div className={styles.statsDivider} />

site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.tsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@ const estimateFinish = (
1818
templateAverage *= 1.2
1919

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

24-
if (realPercentage > 1) {
25-
return [displayPercentage, "Any moment now..."]
22+
// Showing a full bar is frustrating.
23+
if (realPercentage > 0.95) {
24+
return [0.95, "Any moment now..."]
2625
}
2726

2827
return [
29-
displayPercentage,
30-
`${dayjs
31-
.duration((1 - realPercentage) * templateAverage)
32-
.humanize()} remaining...`,
28+
realPercentage,
29+
`~${Math.ceil(
30+
dayjs.duration((1 - realPercentage) * templateAverage).asSeconds(),
31+
)} seconds remaining...`,
3332
]
3433
}
3534

site/src/util/templates.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ export const formatTemplateActiveDevelopers = (num?: number): string => {
1616
export const formatTemplateBuildTime = (buildTimeMs: number): string => {
1717
return buildTimeMs < 0
1818
? "Unknown"
19-
: dayjs.duration(buildTimeMs, "milliseconds").humanize()
19+
: `${Math.round(dayjs.duration(buildTimeMs, "milliseconds").asSeconds())}s`
2020
}

0 commit comments

Comments
 (0)