Skip to content

Commit

Permalink
consider healthy deployments that are more recent than the active one…
Browse files Browse the repository at this point in the history
… as upcoming
  • Loading branch information
nilscox committed Sep 2, 2024
1 parent 7813b05 commit 62c16c2
Showing 1 changed file with 10 additions and 4 deletions.
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

0 comments on commit 62c16c2

Please sign in to comment.