From 2b8004ea168f3e3f5a523ebd85829111ff3a1064 Mon Sep 17 00:00:00 2001 From: Ben Furber Date: Fri, 20 Dec 2024 10:46:41 +0000 Subject: [PATCH] chore: drop question cat cache for non-prod envs --- src/routes/api.questions.categories.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/routes/api.questions.categories.ts b/src/routes/api.questions.categories.ts index a1053aabdc..335ae31216 100644 --- a/src/routes/api.questions.categories.ts +++ b/src/routes/api.questions.categories.ts @@ -1,6 +1,7 @@ import { json } from '@remix-run/node' import { collection, getDocs, query } from 'firebase/firestore' import Keyv from 'keyv' +import { isProductionEnvironment } from 'src/config/config' import { DB_ENDPOINTS } from 'src/models/dbEndpoints' import { firestore } from 'src/utils/firebase' @@ -12,7 +13,9 @@ export const loader = async () => { const cachedCategories = await cache.get('questionCategories') // check if cached categories are available, if not - load from db and cache them - if (cachedCategories) return json({ categories: cachedCategories }) + if (cachedCategories && isProductionEnvironment()) { + return json({ categories: cachedCategories }) + } const collectionRef = collection(firestore, DB_ENDPOINTS.questionCategories) const categories = (await getDocs(query(collectionRef))).docs.map(