diff --git a/api/src/providers/providerStatusProvider.ts b/api/src/providers/providerStatusProvider.ts index 5399cba6f..ad56538d8 100644 --- a/api/src/providers/providerStatusProvider.ts +++ b/api/src/providers/providerStatusProvider.ts @@ -42,93 +42,6 @@ export async function getNetworkCapacity() { }; } -export async function getProviders() { - const nowUtc = toUTC(new Date()); - - const providers = await Provider.findAll({ - where: { - isOnline: true, - deletedHeight: null - }, - include: [ - { - model: ProviderAttribute - }, - { - model: ProviderAttributeSignature - }, - { - model: ProviderSnapshot, - attributes: ["isOnline", "id", "checkDate"], - required: false, - separate: true, - where: { - checkDate: { - [Op.gte]: add(nowUtc, { days: -1 }) - } - } - } - ] - }); - const filteredProviders = providers.filter((value, index, self) => self.map((x) => x.hostUri).indexOf(value.hostUri) === index); - - return filteredProviders.map((x) => { - const isValidVersion = x.cosmosSdkVersion ? semver.gte(x.cosmosSdkVersion, "v0.45.9") : false; - const name = x.isOnline ? new URL(x.hostUri).hostname : null; - - return { - owner: x.owner, - name: name, - hostUri: x.hostUri, - createdHeight: x.createdHeight, - email: x.email, - website: x.website, - lastCheckDate: x.lastCheckDate, - deploymentCount: x.deploymentCount, - leaseCount: x.leaseCount, - cosmosSdkVersion: x.cosmosSdkVersion, - akashVersion: x.akashVersion, - ipRegion: x.ipRegion, - ipRegionCode: x.ipRegionCode, - ipCountry: x.ipCountry, - ipCountryCode: x.ipCountryCode, - ipLat: x.ipLat, - ipLon: x.ipLon, - attributes: x.providerAttributes.map((attr) => ({ - key: attr.key, - value: attr.value, - auditedBy: x.providerAttributeSignatures.filter((pas) => pas.key === attr.key && pas.value === attr.value).map((pas) => pas.auditor) - })), - activeStats: { - cpu: x.activeCPU, - gpu: x.activeGPU, - memory: x.activeMemory, - storage: x.activeStorage - }, - pendingStats: { - cpu: isValidVersion ? x.pendingCPU : 0, - gpu: isValidVersion ? x.pendingGPU : 0, - memory: isValidVersion ? x.pendingMemory : 0, - storage: isValidVersion ? x.pendingStorage : 0 - }, - availableStats: { - cpu: isValidVersion ? x.availableCPU : 0, - gpu: isValidVersion ? x.availableGPU : 0, - memory: isValidVersion ? x.availableMemory : 0, - storage: isValidVersion ? x.availableStorage : 0 - }, - uptime7d: x.uptime7d, - uptime: x.providerSnapshots.map((ps) => ({ - id: ps.id, - isOnline: ps.isOnline, - checkDate: ps.checkDate - })), - isValidVersion, - isOnline: x.isOnline - }; - }); -} - export const getProviderList = async () => { const providers = await Provider.findAll({ where: { diff --git a/api/src/routers/apiRouter.ts b/api/src/routers/apiRouter.ts index ab704bac2..302d0490b 100644 --- a/api/src/routers/apiRouter.ts +++ b/api/src/routers/apiRouter.ts @@ -12,7 +12,7 @@ import { getValidator, getValidators } from "@src/providers/apiNodeProvider"; -import { getNetworkCapacity, getProviderDetail, getProviderList, getProviders } from "@src/providers/providerStatusProvider"; +import { getNetworkCapacity, getProviderDetail, getProviderList } from "@src/providers/providerStatusProvider"; import { getDashboardData, getGraphData, getProviderActiveLeasesGraphData, getProviderGraphData } from "@src/db/statsProvider"; import { round } from "@src/utils/math"; import { isValidBech32Address } from "@src/utils/addresses"; @@ -227,14 +227,6 @@ apiRouter.get( apiRouter.get( "/providers", - asyncHandler(async (req, res) => { - const providers = await getProviders(); - res.send(providers); - }) -); - -apiRouter.get( - "/providerList", asyncHandler(async (req, res) => { const providers = await cacheResponse(60, cacheKeys.getProviderList, getProviderList); res.send(providers); @@ -242,7 +234,7 @@ apiRouter.get( ); apiRouter.get( - "/providerDetail/:address", + "/providers/:address", asyncHandler(async (req, res) => { if (!req.params.address) { res.status(400).send("Address is undefined."); diff --git a/deploy-web/src/pages/deployments/[dseq].tsx b/deploy-web/src/pages/deployments/[dseq].tsx index e2db5184c..b2de3523d 100644 --- a/deploy-web/src/pages/deployments/[dseq].tsx +++ b/deploy-web/src/pages/deployments/[dseq].tsx @@ -99,7 +99,6 @@ const DeploymentDetailPage: React.FunctionComponent = ({ dseq }) => { const hasLeases = leases && leases.length > 0; const { isLocalCertMatching, localCert, isCreatingCert, createCertificate } = useCertificate(); const [deploymentManifest, setDeploymentManifest] = useState(null); - // const { providers, getProviders, isLoadingProviders } = useAkashProviders(); const { data: providers, isFetching: isLoadingProviders, refetch: getProviders } = useProviderList(); const isActive = deployment?.state === "active" && leases?.some(x => x.state === "active"); diff --git a/deploy-web/src/pages/providers/[owner]/index.tsx b/deploy-web/src/pages/providers/[owner]/index.tsx index 159ba8f1f..9852ba025 100644 --- a/deploy-web/src/pages/providers/[owner]/index.tsx +++ b/deploy-web/src/pages/providers/[owner]/index.tsx @@ -242,7 +242,7 @@ export default ProviderDetailPage; export async function getServerSideProps({ params, query }) { const apiUrl = getNetworkBaseApiUrl(query.network as string); - const response = await axios.get(`${apiUrl}/providerDetail/${params?.owner}`); + const response = await axios.get(`${apiUrl}/providers/${params?.owner}`); return { props: { diff --git a/deploy-web/src/queries/useProvidersQuery.ts b/deploy-web/src/queries/useProvidersQuery.ts index 27c79a350..fd839e863 100644 --- a/deploy-web/src/queries/useProvidersQuery.ts +++ b/deploy-web/src/queries/useProvidersQuery.ts @@ -1,11 +1,10 @@ import { useQuery } from "react-query"; import { QueryKeys } from "./queryKeys"; import axios, { AxiosResponse } from "axios"; -import { useSettings } from "../context/SettingsProvider"; -import { ApiUrlService, loadWithPagination } from "@src/utils/apiUtils"; +import { ApiUrlService } from "@src/utils/apiUtils"; import { getNetworkCapacityDto, providerStatusToDto } from "@src/utils/providerUtils"; import { PROVIDER_PROXY_URL } from "@src/utils/constants"; -import { ApiProviderDetail, ApiProviderList, Auditor, RpcProvider } from "@src/types/provider"; +import { ApiProviderDetail, ApiProviderList, Auditor } from "@src/types/provider"; import { ProviderAttributesSchema } from "@src/types/providerAttributes"; async function getProviderDetail(owner: string): Promise { @@ -20,42 +19,6 @@ export function useProviderDetail(owner: string, options) { return useQuery(QueryKeys.getProviderDetailKey(owner), () => getProviderDetail(owner), options); } -// async function getProviders(apiEndpoint: string): Promise> { -// if (apiEndpoint) { -// const providers = await loadWithPagination(ApiUrlService.providers(apiEndpoint), "providers", 1000); - -// return providers; -// } else { -// return null; -// } -// } - -// export function useProviders(options = {}) { -// const { settings } = useSettings(); -// return useQuery(QueryKeys.getProvidersKey(), () => getProviders(settings.apiEndpoint), { -// ...options, -// refetchInterval: false, -// refetchIntervalInBackground: false, -// refetchOnWindowFocus: false, -// refetchOnReconnect: false -// }); -// } - -// async function getDataNodeProviders() { -// const response = await axios.get(ApiUrlService.apiProviders()); -// return response.data; -// } - -// export function useDataNodeProviders(options) { -// return useQuery(QueryKeys.getDataNodeProvidersKey(), () => getDataNodeProviders(), { -// ...options, -// refetchInterval: 15000, -// refetchIntervalInBackground: false, -// refetchOnWindowFocus: true, -// refetchOnReconnect: false -// }); -// } - async function getProviderStatus(providerUri: string) { if (!providerUri) return null; diff --git a/deploy-web/src/utils/apiUtils.ts b/deploy-web/src/utils/apiUtils.ts index cd2ce693f..8a0e09548 100644 --- a/deploy-web/src/utils/apiUtils.ts +++ b/deploy-web/src/utils/apiUtils.ts @@ -19,10 +19,10 @@ export class ApiUrlService { return `${apiEndpoint}/akash/provider/${networkVersion}/providers`; } static providerList() { - return `${BASE_API_URL}/providerList`; + return `${BASE_API_URL}/providers`; } static providerDetail(owner: string) { - return `${BASE_API_URL}/providerDetail/${owner}`; + return `${BASE_API_URL}/providers/${owner}`; } static block(apiEndpoint: string, id: string) { return `${apiEndpoint}/blocks/${id}`;