Skip to content

Commit e177950

Browse files
committed
don't break next/landing page compute server templates
1 parent ab92aa1 commit e177950

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/packages/frontend/compute/public-templates.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Select, Spin, Tag, Tooltip } from "antd";
22
import { useEffect, useState } from "react";
3-
import { getTemplates } from "@cocalc/frontend/compute/api";
3+
import api from "@cocalc/frontend/client/api";
4+
import TTL from "@isaacs/ttlcache";
45
import type { ConfigurationTemplate } from "@cocalc/util/compute/templates";
56
import type { HyperstackConfiguration } from "@cocalc/util/db-schema/compute-servers";
67
import { CLOUDS_BY_NAME } from "@cocalc/util/compute/cloud/clouds";
@@ -13,6 +14,17 @@ import { filterOption } from "@cocalc/frontend/compute/util";
1314
import DisplayCloud from "./display-cloud";
1415
import { Icon } from "@cocalc/frontend/components/icon";
1516

17+
const templatesCache = new TTL({ ttl: 60 * 1000 * 15 });
18+
export async function getTemplates() {
19+
if (templatesCache.has("templates")) {
20+
return templatesCache.get("templates")!;
21+
}
22+
// use nextjs api instead of conat, since this component is used on the landing page.
23+
const x = await api("compute/get-templates");
24+
templatesCache.set("templates", x);
25+
return x;
26+
}
27+
1628
const { CheckableTag } = Tag;
1729

1830
const TAGS = {

src/packages/server/compute/database-cache.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ export function createTTLCache({
102102
// -- list of all volumes defined in hyperstack
103103
// -- hyperstack pricing data
104104

105-
type GetFunction<T> = (opts?: { noCache?: boolean }) => Promise<T>;
105+
type GetFunction<T> = (opts?: {
106+
noCache?: boolean;
107+
account_id?: string;
108+
}) => Promise<T>;
106109

107110
export function createDatabaseCachedResource<T>({
108111
cloud,

0 commit comments

Comments
 (0)