Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ const fallbackListRoute = createRoute({
summary: "List deployments (database fallback)",
tags: ["Deployments"],
security: SECURITY_NONE,
cache: { maxAge: 10, staleWhileRevalidate: 30 },
request: {
query: FallbackDeploymentListQuerySchema
},
Expand Down Expand Up @@ -336,6 +337,7 @@ const fallbackInfoRoute = createRoute({
summary: "Get deployment info (database fallback)",
tags: ["Deployments"],
security: SECURITY_NONE,
cache: { maxAge: 10, staleWhileRevalidate: 30 },
request: {
query: FallbackDeploymentInfoQuerySchema
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { Deployment, DeploymentGroup, DeploymentGroupResource } from "@akashnetw
import { inject, singleton } from "tsyringe";

import { USDC_IBC_DENOMS } from "@src/billing/config/network.config";
import { cacheResponse, Memoize } from "@src/caching/helpers";
import type { CoreConfig } from "@src/core/providers/config.provider";
import { CORE_CONFIG } from "@src/core/providers/config.provider";
import { DeploymentRepository } from "@src/deployment/repositories/deployment/deployment.repository";
import { DatabaseDeploymentListParams } from "@src/deployment/repositories/deployment/deployment.repository";
import { RestAkashDeploymentInfoResponse } from "@src/types/rest/akashDeploymentInfoResponse";
import { RestAkashDeploymentListResponse } from "@src/types/rest/akashDeploymentListResponse";
import { averageBlockTime } from "@src/utils/constants";

export const UNKNOWN_DB_PLACEHOLDER = "unknown_value";

Expand All @@ -23,6 +25,10 @@ export class FallbackDeploymentReaderService {
}

async findAll(params: DatabaseDeploymentListParams): Promise<RestAkashDeploymentListResponse> {
return cacheResponse(averageBlockTime, `FallbackDeploymentReaderService#findAll#${JSON.stringify(params)}`, () => this.findAllUncached(params));
}

private async findAllUncached(params: DatabaseDeploymentListParams): Promise<RestAkashDeploymentListResponse> {
const { skip = 0, limit = 100, key, countTotal = true } = params;

const { count: total, rows: deployments } = await this.deploymentRepository.findDeploymentsWithPagination(params);
Expand Down Expand Up @@ -94,6 +100,7 @@ export class FallbackDeploymentReaderService {
};
}

@Memoize({ ttlInSeconds: averageBlockTime })
Comment thread
baktun14 marked this conversation as resolved.
async findByOwnerAndDseq(owner: string, dseq: string): Promise<RestAkashDeploymentInfoResponse | null> {
const deployment = await this.deploymentRepository.findByIdWithGroups(owner, dseq);

Expand Down
Loading