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

BUG: overwriting in cloud #963

Merged
merged 2 commits into from
Dec 7, 2023
Merged
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
19 changes: 0 additions & 19 deletions agenta-web/src/lib/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@ export const getVariantParametersFromOpenAPI = async (
}
}

// Define a type for our cache
interface Cache {
[key: string]: string
}

// Create the cache object
const urlCache: Cache = {}

/**
* Retries the container url for an app
* @param {string} appId - The id of the app
Expand All @@ -190,21 +182,10 @@ export const getAppContainerURL = async (
throw new Error("Environment variable NEXT_PUBLIC_AGENTA_API_URL is not set.")
}

let cacheKey = appId
if (variantId) cacheKey += `_${variantId}`
if (baseId) cacheKey += `_${baseId}`

// Check if the URL is already cached
if (urlCache[cacheKey]) {
return urlCache[cacheKey]
}

// Retrieve container URL from backend
const url = `${getAgentaApiUrl()}/api/containers/container_url/`
const response = await axios.get(url, {params: {variant_id: variantId, base_id: baseId}})
if (response.status === 200 && response.data && response.data.uri) {
// Cache the URL before returning
urlCache[cacheKey] = response.data.uri
return response.data.uri
} else {
return ""
Expand Down
Loading