Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Karetnikov committed Nov 8, 2023
1 parent 69d3673 commit 5408bba
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
4 changes: 3 additions & 1 deletion src/features/metadata/components/EnvBuilds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const EnvBuilds = ({
Status: {""}
<Typography component="span" sx={{ fontSize: "13px" }}>
{currentBuild.status_info ? (
<>{currentBuild.status} ({currentBuild.status_info})</>
<>
{currentBuild.status} ({currentBuild.status_info})
</>
) : (
<>{currentBuild.status}</>
)}
Expand Down
78 changes: 40 additions & 38 deletions src/utils/helpers/buildMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,48 +41,50 @@ const dateToTimezone = (date: string) => {
};

export const buildMapper = (data: Build[], currentBuildId: number) => {
return data.map(({ id, status, status_info, ended_on, scheduled_on }: Build) => {
let duration = 0;
if (ended_on && scheduled_on) {
const startTime = new Date(scheduled_on);
const endTime = new Date(ended_on);
duration = (endTime.valueOf() - startTime.valueOf()) / 60000;
duration = Math.round(duration);
}
if (id === currentBuildId) {
return {
id,
name: `${dateToTimezone(ended_on ?? scheduled_on)} - Active`,
status: isCompleted(status, duration),
status_info,
};
}
return data.map(
({ id, status, status_info, ended_on, scheduled_on }: Build) => {
let duration = 0;
if (ended_on && scheduled_on) {
const startTime = new Date(scheduled_on);
const endTime = new Date(ended_on);
duration = (endTime.valueOf() - startTime.valueOf()) / 60000;
duration = Math.round(duration);
}
if (id === currentBuildId) {
return {
id,
name: `${dateToTimezone(ended_on ?? scheduled_on)} - Active`,
status: isCompleted(status, duration),
status_info
};
}

if (isBuilding(status)) {
return {
id,
name: `${dateToTimezone(scheduled_on)} - Building`,
status: "Building",
status_info,
};
}
if (isBuilding(status)) {
return {
id,
name: `${dateToTimezone(scheduled_on)} - Building`,
status: "Building",
status_info
};
}

if (isQueued(status)) {
return {
id,
name: `${dateToTimezone(scheduled_on)} - Queued`,
status: "Building",
status_info
};
}

if (isQueued(status)) {
return {
id,
name: `${dateToTimezone(scheduled_on)} - Queued`,
status: "Building",
status_info,
name: `${dateToTimezone(ended_on ?? scheduled_on)} - ${
STATUS_OPTIONS[status]
}`,
status: isCompleted(status, duration),
status_info
};
}

return {
id,
name: `${dateToTimezone(ended_on ?? scheduled_on)} - ${
STATUS_OPTIONS[status]
}`,
status: isCompleted(status, duration),
status_info,
};
});
);
};

0 comments on commit 5408bba

Please sign in to comment.