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(deploy-web): fix provider page #177

Merged
merged 1 commit into from
May 1, 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
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
Loading