Skip to content

Commit

Permalink
www: Expose build lock duration
Browse files Browse the repository at this point in the history
  • Loading branch information
p12tic committed Dec 31, 2023
1 parent 96a8e02 commit 5eafd95
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
9 changes: 4 additions & 5 deletions www/react-base/src/components/BuildSummary/BuildSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
BadgeStatus,
ConfigContext,
analyzeStepUrls,
buildDurationFormatWithLocks,
durationFormat,
useCurrentTime,
useStateWithParentTrackingWithDefaultIfNotSet,
Expand Down Expand Up @@ -303,6 +304,8 @@ export const BuildSummary = observer(({build, parentBuild, parentRelationship,
parentFullDisplay={fullDisplay}/>
));

const durationString = buildDurationFormatWithLocks(build, now);

return (
<Card className={"bb-build-summary " + results2class(build, null)}>
<Card.Header>
Expand All @@ -324,11 +327,7 @@ export const BuildSummary = observer(({build, parentBuild, parentRelationship,
}
{reason !== null ? <span>| {reason}</span> : <></>}
<div className={"bb-build-summary-details"}>
{
build.complete
? <span>{durationFormat(build.complete_at! - build.started_at)}&nbsp;</span>
: <span>{durationFormat(now - build.started_at)}&nbsp;</span>
}
<span>{durationString}&nbsp;</span>
<span>{build.state_string}&nbsp;</span>
<BadgeStatus className={results2class(build, null)}>{results2text(build)}</BadgeStatus>
{renderParentBuildLink()}
Expand Down
9 changes: 3 additions & 6 deletions www/react-base/src/components/BuildsTable/BuildsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
} from "buildbot-data-js";
import {
BuildLinkWithSummaryTooltip,
buildDurationFormatWithLocks,
dateFormat,
durationFormat,
durationFromNowFormat,
useCurrentTime
} from "buildbot-ui";
Expand All @@ -51,12 +51,9 @@ export const BuildsTable = observer(({builds, builders}: BuildsTableProps) => {
? <></>
: <td>{builder === null ? "" : builder.name}</td>

const durationString = buildDurationFormatWithLocks(build, now);
const buildCompleteInfoElement = build.complete
? (
<span title={durationFormat(build.complete_at! - build.started_at)}>
{durationFormat(build.complete_at! - build.started_at)}
</span>
)
? <span title={durationString}>{durationString}</span>
: <></>;

return (
Expand Down
3 changes: 3 additions & 0 deletions www/react-data-module/src/data/classes/Build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class Build extends BaseClass {
@observable started_at!: number;
@observable complete_at!: number|null;
@observable complete!: boolean;
@observable locks_duration_s!: number;
@observable state_string!: string;
@observable results!: number|null;
@observable properties!: {[key: string]: any}; // for subscription to properties use getProperties()
Expand All @@ -43,6 +44,7 @@ export class Build extends BaseClass {
this.started_at = object.started_at;
this.complete_at = object.complete_at;
this.complete = object.complete;
this.locks_duration_s = object.locks_duration_s;
this.results = object.results;
this.state_string = object.state_string;
this.properties = object.properties ?? {};
Expand All @@ -59,6 +61,7 @@ export class Build extends BaseClass {
started_at: this.started_at,
complete_at: this.complete_at,
complete: this.complete,
locks_duration_s: this.locks_duration_s,
state_string: this.state_string,
results: this.results,
properties: this.properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
results2text
} from "buildbot-data-js";
import {ConfigContext} from "../../contexts/Config";
import {buildDurationFormatWithLocks} from "../../util/DataUtils";
import {durationFormat, useCurrentTime} from "../../util/Moment";
import {analyzeStepUrls, useStepUrlAnalyzer} from "../../util/StepUrls";
import {BadgeRound} from "../BadgeRound/BadgeRound";
Expand Down Expand Up @@ -91,11 +92,7 @@ export const BuildSummaryTooltip = observer(({build}: BuildSummaryTooltipProps)
headerElements.push((
<div key="result" className="flex-row">
<div className="flex-grow-1">
{
build.complete
? <span>{durationFormat(build.complete_at! - build.started_at)}</span>
: <span>{durationFormat(now - build.started_at)}</span>
}
{ buildDurationFormatWithLocks(build, now) }
&nbsp;
{ limitStringLength(build.state_string, 80) }
&nbsp;
Expand Down
14 changes: 13 additions & 1 deletion www/react-ui/src/util/DataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
Copyright Buildbot Team Members
*/

import {Builder, DataCollection, Master} from "buildbot-data-js";
import {Build, Builder, DataCollection, Master} from "buildbot-data-js";
import {durationFormat} from "./Moment";

export function hasActiveMaster(builder: Builder, masters: DataCollection<Master>) {
if ((builder.masterids == null)) {
Expand All @@ -33,3 +34,14 @@ export function hasActiveMaster(builder: Builder, masters: DataCollection<Master
}
return active;
};

export function buildDurationFormatWithLocks(build: Build, now: number) {
let res = build.complete
? durationFormat(build.complete_at! - build.started_at)
: durationFormat(now - build.started_at);

if (build.locks_duration_s > 0) {
res += ` (locks: ${durationFormat(build.locks_duration_s!)})`;
}
return res;
}

0 comments on commit 5eafd95

Please sign in to comment.