diff --git a/infra/app/ddd.bicep b/infra/app/ddd.bicep index 8d1b5ae..e581294 100644 --- a/infra/app/ddd.bicep +++ b/infra/app/ddd.bicep @@ -200,7 +200,7 @@ resource app 'Microsoft.App/containerApps@2024-03-01' = { } ] scale: { - minReplicas: 1 + minReplicas: 2 maxReplicas: 10 } } diff --git a/website/app/routes/app-announcements.tsx b/website/app/routes/app-announcements.tsx index e14f518..6c36ec6 100644 --- a/website/app/routes/app-announcements.tsx +++ b/website/app/routes/app-announcements.tsx @@ -1,5 +1,7 @@ +import { trace } from '@opentelemetry/api' import { json } from '@remix-run/server-runtime' import { CACHE_CONTROL } from '~/lib/http.server' +import { resolveError } from '~/lib/resolve-error' export type GoogleFormUpdates = { Timestamp: string @@ -14,29 +16,39 @@ export async function loader() { return new Response(JSON.stringify({ message: 'No Google Forms API key or form ID' }), { status: 404 }) } - const BASE_URL = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&key=${apiKey}` + try { + const BASE_URL = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&key=${apiKey}` - const response = await fetch(BASE_URL, { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - }) + const response = await fetch(BASE_URL, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }) + + const responseData = (await response.json()) as GoogleFormUpdates[] - const responseData = (await response.json()) as GoogleFormUpdates[] + const announcementData = responseData + .map((row) => { + return { createdTime: row.Timestamp, update: row.Message } + }) + .sort((a, b) => { + return new Date(b.createdTime).getTime() - new Date(a.createdTime).getTime() + }) - const announcementData = responseData - .map((row) => { - return { createdTime: row.Timestamp, update: row.Message } + return json(announcementData, { + headers: { + 'Cache-Control': CACHE_CONTROL.announce, + 'Access-Control-Allow-Origin': '*', + }, }) - .sort((a, b) => { - return new Date(b.createdTime).getTime() - new Date(a.createdTime).getTime() + } catch (err) { + trace.getActiveSpan()?.recordException(resolveError(err)) + return json([], { + headers: { + 'Cache-Control': CACHE_CONTROL.announce, + 'Access-Control-Allow-Origin': '*', + }, }) - - return json(announcementData, { - headers: { - 'Cache-Control': CACHE_CONTROL.announce, - 'Access-Control-Allow-Origin': '*', - }, - }) + } }