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

Avoid showing upcoming healthy deployments in the history section #10

Merged
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
14 changes: 10 additions & 4 deletions src/pages/service/overview/service-overview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useInfiniteQuery } from '@tanstack/react-query';
import { isAfter } from 'date-fns';
import { useCallback, useEffect, useMemo, useState } from 'react';

import { useBreakpoint } from '@koyeb/design-system';
Expand Down Expand Up @@ -203,14 +204,19 @@ function useDeployments(serviceId: string) {

function useDeploymentGroups(service: Service, deployments: ComputeDeployment[]) {
return useMemo(() => {
let active: ComputeDeployment | undefined = undefined;
const active = deployments.find(hasProperty('id', service.activeDeploymentId));
const upcoming: ComputeDeployment[] = [];
const past: ComputeDeployment[] = [];

for (const deployment of deployments) {
if (deployment.id === service.activeDeploymentId) {
active = deployment;
} else if (isUpcomingDeployment(deployment)) {
if (deployment === active) {
continue;
}

if (isUpcomingDeployment(deployment)) {
upcoming.push(deployment);
} else if (deployment.status === 'healthy' && active && isAfter(deployment.date, active.date)) {
// consider healthy deployments that are more recent than the active one as upcoming
upcoming.push(deployment);
} else {
past.push(deployment);
Expand Down