Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
wip(frontend): list catalog runs
Browse files Browse the repository at this point in the history
  • Loading branch information
evoxmusic committed Jan 6, 2024
1 parent a4a784d commit 71fb513
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/src/catalog/controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub async fn exec_catalog_service_post_validate_scripts(
&service_slug,
Status::Queued,
&req.payload,
&serde_json::Value::Object(serde_json::Map::new()),
&serde_json::Value::Array(vec![]),
).await {
Ok(ces) => ces,
Err(err) => return (StatusCode::INTERNAL_SERVER_ERROR, Json(JobResponse {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/catalog/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub async fn background_worker(mut rx: Receiver<BackgroundWorkerTask>, pg_pool:
&pg_pool,
task.catalog_execution_status_id.as_str(),
Status::Running,
&serde_json::Value::Object(serde_json::Map::new()),
&serde_json::Value::Array(vec![]),
).await;

if let Err(err) = r {
Expand Down
25 changes: 23 additions & 2 deletions frontend/src/components/self-service/SelfServiceRunTable.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import {millisToHumanTime} from "@/lib/utils.ts";
import {classNames, millisToHumanTime} from "@/lib/utils.ts";

const statuses = {
QUEUED: 'text-orange-400 bg-orange-400/10',
RUNNING: 'text-cyan-400 bg-cyan-400/10',
SUCCESS: 'text-green-400 bg-green-400/10',
FAILURE: 'text-rose-400 bg-rose-400/10'
}

interface Props {
runs: any[]
}

function getTotalExecutionTime(tasks: any[]): number {
if (tasks === undefined || tasks.length === 0) {
return 0
}

return tasks.reduce((acc, task) => {
if (task.post_validate_output && task.post_validate_output.execution_time_in_millis) {
return acc + task.post_validate_output.execution_time_in_millis
Expand Down Expand Up @@ -49,7 +60,17 @@ export default function SelfServiceRunTable({runs}: Props): JSX.Element {
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-500 sm:pl-6 lg:pl-8">
{run.created_at}
</td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{run.status}</td>
<td className="py-4 pl-0 pr-4 text-sm leading-6 sm:pr-8 lg:pr-20">
<div className="flex items-center justify-end gap-x-2 sm:justify-start">
<time className="text-gray-400 sm:hidden" dateTime={run.created_at}>
{run.created_at}
</time>
<div className={classNames(statuses[run.status], 'flex-none rounded-full p-1')}>
<div className="h-1.5 w-1.5 rounded-full bg-current"/>
</div>
<div className="hidden text-gray-500 text- sm:block">{run.status}</div>
</div>
</td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{run.tasks.length}/{run.tasks.length}</td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{millisToHumanTime(getTotalExecutionTime(run.tasks))}</td>
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6 lg:pr-8">
Expand Down

0 comments on commit 71fb513

Please sign in to comment.