Skip to content

Commit

Permalink
Merge pull request #21 from dontnod/4.x/www/reduce-logs-queries
Browse files Browse the repository at this point in the history
www: BuildSummary only query logs if needed for display
  • Loading branch information
tdesveaux authored Sep 23, 2024
2 parents f9c1298 + e5669ce commit bb8c944
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions newsfragments/www-reduce-logs-queries.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce log queries in BuildView (`builders/:builderid/builds/:buildnumber`) when logs won't be displayed.
9 changes: 4 additions & 5 deletions www/base/src/components/BuildSummary/BuildSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ const getStepLogsInDisplayOrder = (logs: DataCollection<Log>) => {
type BuildSummaryStepLineProps = {
build: Build;
step: Step;
logs: DataCollection<Log>;
parentFullDisplay: boolean
}

const BuildSummaryStepLine = observer(({build, step, logs, parentFullDisplay}: BuildSummaryStepLineProps) => {
const BuildSummaryStepLine = observer(({build, step, parentFullDisplay}: BuildSummaryStepLineProps) => {
const config = useContext(ConfigContext);
const now = useCurrentTime();

Expand All @@ -124,6 +123,8 @@ const BuildSummaryStepLine = observer(({build, step, logs, parentFullDisplay}: B
const [fullDisplay, setFullDisplay] = useStateWithParentTrackingWithDefaultIfNotSet(
parentFullDisplay, () => !step.complete || (step.results !== SUCCESS));

const logs = useDataApiQuery(() => step.getLogs());

const renderState = () => {
if (step.started_at === null) {
return <></>;
Expand Down Expand Up @@ -201,7 +202,7 @@ const BuildSummaryStepLine = observer(({build, step, logs, parentFullDisplay}: B
</li>
))}
</ul>
{renderStepLogs()}
{fullDisplay ? renderStepLogs() : <></>}
</div>
);
}
Expand Down Expand Up @@ -247,7 +248,6 @@ export const BuildSummary = observer(({build, parentBuild, parentRelationship,
() => parentBuild === null
? new DataCollection<Builder>()
: Builder.getAll(accessor, {id: parentBuild.builderid.toString()}));
const logsQuery = useDataApiQuery(() => stepsQuery.getRelated(step => step.getLogs()));

const [detailLevel, setDetailLevel] =
useState<DetailLevel>(condensed ? DetailLevel.OnlyFailures : DetailLevel.Everything);
Expand Down Expand Up @@ -287,7 +287,6 @@ export const BuildSummary = observer(({build, parentBuild, parentRelationship,

const stepElements = stepsToDisplay.map(step => (
<BuildSummaryStepLine key={step.id} build={build} step={step}
logs={logsQuery.getParentCollectionOrEmpty(step.id)}
parentFullDisplay={fullDisplay}/>
));

Expand Down

0 comments on commit bb8c944

Please sign in to comment.