Skip to content

Commit

Permalink
fix(deploy-web): fix provider page
Browse files Browse the repository at this point in the history
  • Loading branch information
Redm4x committed May 1, 2024
1 parent 47935e7 commit 3ad6ab0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/src/types/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ProviderList {
uptime30d: number;
isValidVersion: boolean;
isOnline: boolean;
lastOnlineDate: Date;
isAudited: boolean;
gpuModels: { vendor: string; model: string; ram: string; interface: string }[];
activeStats: {
Expand Down
6 changes: 3 additions & 3 deletions deploy-web/src/pages/providers/[owner]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ProviderDetailPage: React.FunctionComponent<Props> = ({ owner, _provider }
function groupUptimeChecksByPeriod(uptimeChecks: { isOnline: boolean; checkDate: string }[] = []) {
const groupedSnapshots: { checkDate: Date; checks: boolean[] }[] = [];

const sortedUptimeChecks = uptimeChecks.toSorted((a, b) => new Date(a.checkDate).getTime() - new Date(b.checkDate).getTime());
const sortedUptimeChecks = [...uptimeChecks].sort((a, b) => new Date(a.checkDate).getTime() - new Date(b.checkDate).getTime());

for (const snapshot of sortedUptimeChecks) {
const recentGroup = groupedSnapshots.find(x => differenceInMinutes(new Date(snapshot.checkDate), x.checkDate) < 15);
Expand All @@ -113,7 +113,7 @@ const ProviderDetailPage: React.FunctionComponent<Props> = ({ owner, _provider }
}

const uptimePeriods = useMemo(() => groupUptimeChecksByPeriod(provider?.uptime || []), [provider?.uptime]);
const wasRecentlyOnline = provider && (provider.isOnline || (provider.lastCheckDate && new Date(provider.lastCheckDate) >= sub(new Date(), { hours: 24 })));
const wasRecentlyOnline = provider && (provider.isOnline || (provider.lastOnlineDate && new Date(provider.lastOnlineDate) >= sub(new Date(), { hours: 24 })));

return (
<Layout isLoading={isLoading}>
Expand All @@ -126,7 +126,7 @@ const ProviderDetailPage: React.FunctionComponent<Props> = ({ owner, _provider }
</Box>
)}

{provider && !wasRecentlyOnline && !isLoading && (
{provider && !wasRecentlyOnline && !isLoadingProvider && (
<Alert
variant="outlined"
severity="warning"
Expand Down
1 change: 1 addition & 0 deletions deploy-web/src/types/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export interface ApiProviderList {
uptime30d: number;
isValidVersion: boolean;
isOnline: boolean;
lastOnlineDate: string;
isAudited: boolean;
gpuModels: { vendor: string; model: string; ram: string; interface: string }[];
activeStats: {
Expand Down

0 comments on commit 3ad6ab0

Please sign in to comment.