Skip to content

Commit

Permalink
added time to completion feature
Browse files Browse the repository at this point in the history
Signed-off-by: Duncan Ragsdale <[email protected]>
  • Loading branch information
Thistleman committed Oct 2, 2024
1 parent 5eae652 commit 0cb8a9f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/modules/mysubmissions/reportItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Submissions = {
submittedAt: number;
altName: string;
analysis: Analysis;
ttc: string;
}

/**
Expand Down Expand Up @@ -167,6 +168,26 @@ export default function SubmissionList() {
return params !== null && params !== undefined ? formatDate : 'N/A';
},
},
{
field: 'ttc',
headerName: 'Time to Completion',
flex: 1,
filterable: false,
sortable: false,
groupable: false,
renderCell: (params: any) => {
const {value} = params;
if (value !== null || value !== undefined) {
return (
<div className="">
{value}
</div>
);
} else {
return 'N/A';
}
},
},
{
field: 'actions',
headerName: 'Actions',
Expand Down
23 changes: 23 additions & 0 deletions src/services/submission_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,29 @@ const SubmissionService = {
formatAllSubmissionsForUser(response: any) {
const finalResponse = [];
if (response.length > 0) {
// ttc = time to completion
console.log('response', response);
for (let i = 0; i < response.length; i += 1) {
let ttc;
if (
(response[i].current_file_count > 0 &&
response[i].analysis.total_files %
response[i].current_file_count === 0) ||
response[i].status === 'finished') {
ttc = 'Done';
} else if (response[i].current_file_count === 0 &&
response[i].status === 'running'
) {
ttc = 'Calculating...';
} else if (response[i].current_file_count > 0) {
const filesLeft = response[i].analysis.total_files -
response[i].current_file_count;
const avgTime = response[i].avg_file_exec_time;
const timeLeft = (filesLeft * avgTime).toFixed(0);
ttc = `~${timeLeft} seconds`;
} else {
ttc = 'Check Status';
}
const element = {
id: response[i].submission_id,
status: response[i].status,
Expand All @@ -42,6 +64,7 @@ const SubmissionService = {
subStatus: response[i].status,
analysis: response[i].analysis,
archived: response[i].archived,
ttc,
};
finalResponse.push(element);
}
Expand Down

0 comments on commit 0cb8a9f

Please sign in to comment.