Skip to content

Commit

Permalink
perf: code shorten
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhiter committed Dec 17, 2024
1 parent 454d4e0 commit 0e11709
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions frontend/providers/devbox/app/api/platform/getRuntime/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,10 @@ export async function GET(req: NextRequest) {
const languageList = runtimeClasses?.items.filter((item: any) => item.spec.kind === 'Language')
const dealtLanguageList = languageList.map((item: any) => {
const aRuntime = runtimes.find((runtime: any) => runtime.spec.classRef === item.metadata.name)
if (aRuntime?.spec.category?.includes('gpu')) {
return {
id: item.metadata.name,
label: item.spec.title,
gpu: true
}
}
return {
id: item.metadata.name,
label: item.spec.title,
gpu: false
gpu: !!aRuntime?.spec.category?.includes('gpu')
}
})
languageTypeList.push(...dealtLanguageList)
Expand All @@ -69,35 +62,21 @@ export async function GET(req: NextRequest) {
)
const dealtFrameworkList = frameworkList.map((item: any) => {
const aRuntime = runtimes.find((runtime: any) => runtime.spec.classRef === item.metadata.name)
if (aRuntime?.spec.category?.includes('gpu')) {
return {
id: item.metadata.name,
label: item.spec.title,
gpu: true
}
}
return {
id: item.metadata.name,
label: item.spec.title,
gpu: false
gpu: !!aRuntime?.spec.category?.includes('gpu')
}
})
frameworkTypeList.push(...dealtFrameworkList)

const osList = runtimeClasses?.items.filter((item: any) => item.spec.kind === 'OS')
const dealtOsList = osList.map((item: any) => {
const aRuntime = runtimes.find((runtime: any) => runtime.spec.classRef === item.metadata.name)
if (aRuntime?.spec.category?.includes('gpu')) {
return {
id: item.metadata.name,
label: item.spec.title,
gpu: true
}
}
return {
id: item.metadata.name,
label: item.spec.title,
gpu: false
gpu: !!aRuntime?.spec.category?.includes('gpu')
}
})
osTypeList.push(...dealtOsList)
Expand Down

0 comments on commit 0e11709

Please sign in to comment.