Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix workflow counts and reactive selectedId #2319

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/lib/components/event/event-summary-row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
export let active = false;
export let onRowClick: () => void = noop;

let selectedId = isEventGroup(event)
$: selectedId = isEventGroup(event)
? Array.from(event.events.keys()).pop()
: event.id;

Expand Down Expand Up @@ -193,7 +193,16 @@
<div class="flex items-center gap-2 px-2">
<div class="flex gap-0.5">
{#each event.eventList as groupEvent}
<Link class="truncate" data-testid="link" {href}>
<Link
class="truncate"
data-testid="link"
href={routeForEventHistoryEvent({
eventId: groupEvent.id,
namespace,
workflow,
run,
})}
>
{groupEvent.id}
</Link>
{/each}
Expand Down
40 changes: 33 additions & 7 deletions src/lib/components/workflow/workflow-counts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@

import { page } from '$app/stores';

import Link from '$lib/holocene/link.svelte';
import Skeleton from '$lib/holocene/skeleton/index.svelte';
import { workflowStatuses } from '$lib/models/workflow-status';
import { fetchWorkflowCountByExecutionStatus } from '$lib/services/workflow-counts';
import { workflowFilters } from '$lib/stores/filters';
import { currentPageKey } from '$lib/stores/pagination';
import {
queryWithParentWorkflowId,
refresh,
workflowCount,
} from '$lib/stores/workflows';
import type { WorkflowStatus } from '$lib/types/workflows';
import {
SEARCH_ATTRIBUTE_TYPE,
type WorkflowStatus,
} from '$lib/types/workflows';
import { decodePayload } from '$lib/utilities/decode-payload';
import { toListWorkflowQueryFromFilters } from '$lib/utilities/query/filter-workflow-query';
import { combineFilters } from '$lib/utilities/query/to-list-workflow-filters';
import { getExponentialBackoffSeconds } from '$lib/utilities/refresh-rate';
import { updateQueryParameters } from '$lib/utilities/update-query-parameters';

import WorkflowCountStatus from './workflow-count-status.svelte';

Expand Down Expand Up @@ -116,24 +123,43 @@
}
};

const onStatusClick = (status) => {
const filter = {
attribute: 'ExecutionStatus',
type: SEARCH_ATTRIBUTE_TYPE.KEYWORD,
value: status,
operator: '',
conditional: '=',
parenthesis: '',
};
Comment on lines +127 to +134
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a type or a function to generate this filter?

Copy link
Contributor Author

@Alex-Tideman Alex-Tideman Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function to create a filter is tangled up in the Context for the workflow filter search stuff. But it's typed and would blow up if in the $workflowFilters = [...$workflowFilters, filter] logic

$workflowFilters = [...$workflowFilters, filter];
const searchQuery = toListWorkflowQueryFromFilters(
combineFilters($workflowFilters),
);
updateQueryParameters({
url: $page.url,
parameter: 'query',
value: searchQuery,
allowEmpty: true,
clearParameters: [currentPageKey],
});
};

$: query, namespace, $refresh, fetchCounts();
</script>

<div class="flex min-h-[24px] flex-wrap items-center gap-2">
{#each statusGroups as { count, status } (status)}
{#if !loading}
<Link
href={`/namespaces/${namespace}/workflows?query=%60ExecutionStatus%60%3D"${status}"`}
role="button"
>
<button on:click={() => onStatusClick(status)}>
<WorkflowCountStatus
{status}
{count}
newCount={newStatusGroups.find((g) => g.status === status)
? newStatusGroups.find((g) => g.status === status).count - count
: 0}
/>
</Link>
</button>
{:else}
<Skeleton class="h-6 w-24 rounded" />
{/if}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/models/event-groups/create-event-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ const createGroupFor = <K extends keyof StartingEvents>(
},
get isPending() {
return (
this.pendingActivity ||
this.pendingNexusOperation ||
!!this.pendingActivity ||
!!this.pendingNexusOperation ||
(isTimerStartedEvent(this.initialEvent) &&
this.eventList.length === 1) ||
(isStartChildWorkflowExecutionInitiatedEvent(this.initialEvent) &&
Expand Down
12 changes: 7 additions & 5 deletions src/lib/utilities/get-failed-or-pending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ export const getFailedOrPendingEvents = (
return items.filter(
(item) =>
(isEvent(item) && item.classification === 'Failed') ||
(isEvent(item) && item.classification === 'TimedOut') ||
isPendingActivity(item) ||
isPendingNexusOperation(item) ||
(isEventGroup(item) &&
(item.pendingActivity ||
item.pendingNexusOperation ||
item.finalClassification === 'Failed')),
(item.isPending ||
item.finalClassification === 'Failed' ||
item.finalClassification === 'TimedOut')),
);
};

Expand All @@ -33,7 +34,8 @@ export const getFailedOrPendingGroups = (
return items.filter(
(item) =>
isEventGroup(item) &&
item.eventList.length > 1 &&
(item.isPending || item.finalClassification === 'Failed'),
(item.isPending ||
item.finalClassification === 'Failed' ||
item.finalClassification === 'TimedOut'),
);
};
Loading