From cb24d48049ec2f33a23ddc1a75a7a5be1c763185 Mon Sep 17 00:00:00 2001 From: karthik8239 <43171496+karthik8239@users.noreply.github.com> Date: Wed, 18 Sep 2024 02:32:50 -0400 Subject: [PATCH] feat(api): review tags (#159) --- server/api/review-tags/index.get.ts | 10 ++++++++++ server/utils/tasks/seed-cache.ts | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 server/api/review-tags/index.get.ts diff --git a/server/api/review-tags/index.get.ts b/server/api/review-tags/index.get.ts new file mode 100644 index 00000000..a4c58f71 --- /dev/null +++ b/server/api/review-tags/index.get.ts @@ -0,0 +1,10 @@ +import { type ReviewTag } from '../../db/schema'; +import authenticateAdminRequest from '../../utils/admin'; + +export default defineEventHandler(async (event) => { + await authenticateAdminRequest(event); + + const reviewTags = (await general_memoryStorage.getItem('reviewTags')) || []; + + return reviewTags; +}); diff --git a/server/utils/tasks/seed-cache.ts b/server/utils/tasks/seed-cache.ts index 9ef9ccb5..f397617f 100644 --- a/server/utils/tasks/seed-cache.ts +++ b/server/utils/tasks/seed-cache.ts @@ -1,5 +1,5 @@ import { desc, inArray } from 'drizzle-orm'; -import { jobPostingsTable, metaDataTable } from '~~/server/db/schema'; +import { jobPostingsTable, reviewTagsTable, metaDataTable } from '~~/server/db/schema'; import type { CareerSiteConfig, SEOConfig } from '~~/shared/schemas/setting'; export async function seedCache() { @@ -12,6 +12,8 @@ export async function seedCache() { .from(metaDataTable) .where(inArray(metaDataTable.key, ['seoConfig', 'careerSiteConfig', 'firstSetupAccessKey'])); + const reviewTags = await db.select().from(reviewTagsTable); + // Do not save totalApplicants in cache const jobPostings = (await db.select().from(jobPostingsTable).orderBy(desc(jobPostingsTable.createdAt))).map((p) => ({ ...p, @@ -41,6 +43,7 @@ export async function seedCache() { general_memoryStorage.setItem('firstSetupAccessKey', firstSetupAccessKey), general_memoryStorage.setItem('remoteAssetBase', remoteAssetBase), general_memoryStorage.setItem('postings', jobPostings), + general_memoryStorage.setItem('reviewTags', reviewTags), ]); return { result: true };