Skip to content

Commit

Permalink
[pre-commit.ci] Add auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 16, 2024
1 parent 10d9ed5 commit 3072e45
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 51 deletions.
68 changes: 25 additions & 43 deletions florist/app/jobs/details/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ export function JobDetailsBody(): ReactElement {
</div>
</div>

<JobProgress
serverMetrics={job.server_metrics}
serverConfig={job.server_config}
status={job.status}
/>
<JobProgress serverMetrics={job.server_metrics} serverConfig={job.server_config} status={job.status} />

<JobDetailsTable
Component={JobDetailsServerConfigTable}
Expand Down Expand Up @@ -173,9 +169,9 @@ export function JobProgress({
serverConfig,
status,
}: {
serverMetrics: string,
serverConfig: string,
status: status,
serverMetrics: string;
serverConfig: string;
status: status;
}): ReactElement {
if (!serverMetrics || !serverConfig) {
return null;
Expand Down Expand Up @@ -211,7 +207,7 @@ export function JobProgress({
break;
}
if (progressPercent === 0) {
progressBarClasses += " bg-disabled"
progressBarClasses += " bg-disabled";
}

return (
Expand All @@ -226,7 +222,7 @@ export function JobProgress({
<div
className={progressBarClasses}
role="progressbar"
style={{width: progressWidth}}
style={{ width: progressWidth }}
aria-valuenow={progressPercent}
aria-valuemin="0"
aria-valuemax="100"
Expand All @@ -241,7 +237,7 @@ export function JobProgress({
Expand
<i className="material-icons text-sm">keyboard_arrow_down</i>
</span>
): (
) : (
<span>
Collapse
<i className="material-icons text-sm">keyboard_arrow_up</i>
Expand All @@ -251,12 +247,12 @@ export function JobProgress({
</div>
</div>
<div className="row pb-2">
{!collapsed ? <JobProgressDetails serverMetrics={serverMetricsJson}/> : null}
{!collapsed ? <JobProgressDetails serverMetrics={serverMetricsJson} /> : null}
</div>
</div>
</div>
</div>
)
);
}

export function JobProgressDetails({ serverMetrics }: { serverMetrics: Object }): ReactElement {
Expand Down Expand Up @@ -287,17 +283,13 @@ export function JobProgressDetails({ serverMetrics }: { serverMetrics: Object })
<div className="col-sm-2">
<strong className="text-dark">Start time:</strong>
</div>
<div className="col-sm">
{"fit_start" in serverMetrics ? serverMetrics.fit_start : null}
</div>
<div className="col-sm">{"fit_start" in serverMetrics ? serverMetrics.fit_start : null}</div>
</div>
<div className="row">
<div className="col-sm-2">
<strong className="text-dark">End time:</strong>
</div>
<div className="col-sm">
{"fit_end" in serverMetrics ? serverMetrics.fit_end : null}
</div>
<div className="col-sm">{"fit_end" in serverMetrics ? serverMetrics.fit_end : null}</div>
</div>

{Object.keys(serverMetrics).map((name, i) => (
Expand All @@ -308,10 +300,10 @@ export function JobProgressDetails({ serverMetrics }: { serverMetrics: Object })
<JobProgressRound roundMetrics={roundMetrics} key={i} index={i} />
))}
</div>
)
);
}

export function JobProgressRound({ roundMetrics, index }: { roundMetrics: Object, index: int }): ReactElement {
export function JobProgressRound({ roundMetrics, index }: { roundMetrics: Object; index: int }): ReactElement {
if (!roundMetrics) {
return null;
}
Expand All @@ -331,23 +323,21 @@ export function JobProgressRound({ roundMetrics, index }: { roundMetrics: Object
Expand
<i className="material-icons text-sm">keyboard_arrow_down</i>
</span>
): (
) : (
<span>
Collapse
<i className="material-icons text-sm">keyboard_arrow_up</i>
</span>
)}
</a>
</div>
{!collapsed ?
<JobProgressRoundDetails roundMetrics={roundMetrics} key={index} index={index} />
: null}
{!collapsed ? <JobProgressRoundDetails roundMetrics={roundMetrics} key={index} index={index} /> : null}
</div>
</div>
);
}

export function JobProgressRoundDetails({ roundMetrics, index }: { roundMetrics: Object, index: str }): ReactElement {
export function JobProgressRoundDetails({ roundMetrics, index }: { roundMetrics: Object; index: str }): ReactElement {
if (!roundMetrics) {
return null;
}
Expand Down Expand Up @@ -378,17 +368,13 @@ export function JobProgressRoundDetails({ roundMetrics, index }: { roundMetrics:
<div className="col-sm-2">
<strong className="text-dark">Fit start time:</strong>
</div>
<div className="col-sm">
{"fit_start" in roundMetrics ? roundMetrics.fit_start : null}
</div>
<div className="col-sm">{"fit_start" in roundMetrics ? roundMetrics.fit_start : null}</div>
</div>
<div className="row">
<div className="col-sm-2">
<strong className="text-dark">Fit end time:</strong>
</div>
<div className="col-sm">
{"fit_end" in roundMetrics ? roundMetrics.fit_end : null}
</div>
<div className="col-sm">{"fit_end" in roundMetrics ? roundMetrics.fit_end : null}</div>
</div>
<div className="row">
<div className="col-sm-2">
Expand All @@ -400,17 +386,13 @@ export function JobProgressRoundDetails({ roundMetrics, index }: { roundMetrics:
<div className="col-sm-2">
<strong className="text-dark">Evaluate start time:</strong>
</div>
<div className="col-sm">
{"evaluate_start" in roundMetrics ? roundMetrics.evaluate_start : null}
</div>
<div className="col-sm">{"evaluate_start" in roundMetrics ? roundMetrics.evaluate_start : null}</div>
</div>
<div className="row">
<div className="col-sm-2">
<strong className="text-dark">Evaluate end time:</strong>
</div>
<div className="col-sm">
{"evaluate_end" in roundMetrics ? roundMetrics.evaluate_end : null}
</div>
<div className="col-sm">{"evaluate_end" in roundMetrics ? roundMetrics.evaluate_end : null}</div>
</div>
{Object.keys(roundMetrics).map((name, i) => (
<JobProgressProperty name={name} value={roundMetrics[name]} key={i} />
Expand All @@ -419,7 +401,7 @@ export function JobProgressRoundDetails({ roundMetrics, index }: { roundMetrics:
);
}

export function JobProgressProperty({ name, value }: { name: string, value: string }): ReactElement {
export function JobProgressProperty({ name, value }: { name: string; value: string }): ReactElement {
if (["fit_start", "fit_end", "evaluate_start", "evaluate_end", "rounds", "type"].includes(name)) {
return null;
}
Expand Down Expand Up @@ -569,14 +551,14 @@ export function JobDetailsClientsInfoTable({ data }: { data: Array<ClientInfo> }
}

export function getTimeString(timeInMiliseconds: number): string {
const hours = Math.floor(timeInMiliseconds/1000/60/60);
const minutes = Math.floor((timeInMiliseconds/1000/60/60 - hours) * 60);
const seconds = Math.floor(((timeInMiliseconds/1000/60/60 - hours) * 60 - minutes) * 60);
const hours = Math.floor(timeInMiliseconds / 1000 / 60 / 60);
const minutes = Math.floor((timeInMiliseconds / 1000 / 60 / 60 - hours) * 60);
const seconds = Math.floor(((timeInMiliseconds / 1000 / 60 / 60 - hours) * 60 - minutes) * 60);

let timeString = "";
if (hours <= 0 && minutes <= 0 && seconds < 10) {
// Adding the miliseconds if the time is less than 10s
timeString = `${timeInMiliseconds - (1000 * seconds)}ms`;
timeString = `${timeInMiliseconds - 1000 * seconds}ms`;
}
if (seconds > 0) {
const secondsString = seconds < 10 ? `0${seconds}` : `${seconds}`;
Expand Down
20 changes: 12 additions & 8 deletions florist/tests/unit/app/jobs/details/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe("Job Details Page", () => {
});
it("Display progress bar at 0% when rounds list is empty", () => {
const testJob = makeTestJob();
testJob.server_metrics = JSON.stringify({rounds: {}});
testJob.server_metrics = JSON.stringify({ rounds: {} });
setupGetJobMock(testJob);
const { container } = render(<JobDetails />);
const jobProgressComponent = container.querySelector("#job-progress");
Expand Down Expand Up @@ -308,14 +308,16 @@ describe("Job Details Page", () => {
const customPropertyArray = jobProgressDetailsComponent.children[4];
expect(customPropertyArray.children[0]).toHaveTextContent("custom_property_array");
expect(customPropertyArray.children[1]).toHaveTextContent(
JSON.stringify(serverMetrics.custom_property_array)
JSON.stringify(serverMetrics.custom_property_array),
);
const customPropertyObject = jobProgressDetailsComponent.children[5];
expect(customPropertyObject.children[0]).toHaveTextContent("custom_property_object");
const customPropertyObjectValue = customPropertyObject.children[1];
expect(customPropertyObjectValue.children[0].children[0]).toHaveTextContent("custom_property_object_value");
expect(customPropertyObjectValue.children[0].children[0]).toHaveTextContent(
"custom_property_object_value",
);
expect(customPropertyObjectValue.children[0].children[1]).toHaveTextContent(
serverMetrics.custom_property_object.custom_property_object_value
serverMetrics.custom_property_object.custom_property_object_value,
);

// rounds
Expand Down Expand Up @@ -388,7 +390,7 @@ describe("Job Details Page", () => {
const toggleButton = container.querySelector(`#job-round-toggle-${i} a`);
act(() => toggleButton.click());

console.log(i)
console.log(i);

const jobRoundDetailsComponent = container.querySelector(`#job-round-details-${i}`);
const fitElapsedTime = jobRoundDetailsComponent.children[0];
Expand Down Expand Up @@ -419,14 +421,16 @@ describe("Job Details Page", () => {
const customPropertyArray = jobRoundDetailsComponent.children[7];
expect(customPropertyArray.children[0]).toHaveTextContent("custom_property_array");
expect(customPropertyArray.children[1]).toHaveTextContent(
JSON.stringify(serverMetrics.custom_property_array)
JSON.stringify(serverMetrics.custom_property_array),
);
const customPropertyObject = jobRoundDetailsComponent.children[8];
expect(customPropertyObject.children[0]).toHaveTextContent("custom_property_object");
const customPropertyObjectValue = customPropertyObject.children[1];
expect(customPropertyObjectValue.children[0].children[0]).toHaveTextContent("custom_property_object_value");
expect(customPropertyObjectValue.children[0].children[0]).toHaveTextContent(
"custom_property_object_value",
);
expect(customPropertyObjectValue.children[0].children[1]).toHaveTextContent(
serverMetrics.custom_property_object.custom_property_object_value
serverMetrics.custom_property_object.custom_property_object_value,
);
});
});
Expand Down

0 comments on commit 3072e45

Please sign in to comment.