Skip to content

Commit

Permalink
chore: drop question cat cache for non-prod envs
Browse files Browse the repository at this point in the history
  • Loading branch information
benfurber committed Dec 20, 2024
1 parent ff36538 commit 2b8004e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/routes/api.questions.categories.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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(
Expand Down

0 comments on commit 2b8004e

Please sign in to comment.