Skip to content

Commit

Permalink
feat(api): review tags (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik8239 authored Sep 18, 2024
1 parent 82d86d9 commit cb24d48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions server/api/review-tags/index.get.ts
Original file line number Diff line number Diff line change
@@ -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<ReviewTag[]>('reviewTags')) || [];

return reviewTags;
});
5 changes: 4 additions & 1 deletion server/utils/tasks/seed-cache.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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,
Expand Down Expand Up @@ -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 };
Expand Down

0 comments on commit cb24d48

Please sign in to comment.