Skip to content

Commit

Permalink
feat(career-page): show total postings (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik8239 authored Oct 1, 2024
1 parent bd88682 commit e4d1512
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
5 changes: 5 additions & 0 deletions app/components/Ui/Tag.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<span class="bg-blue-100 px-2 py-1 border border-blue-300 rounded-lg text-blue-700 text-sm">
<slot />
</span>
</template>
4 changes: 4 additions & 0 deletions app/composables/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export function useOnboardingStatusState() {
return useState<boolean>('onboarding-status', () => false);
}

export function useTotalActivePostingsState() {
return useState<number>('total-active-postings', () => 0);
}

export function useCareerSiteConfigObjectState() {
return useObjectState<CareerSiteConfig>('career-site-config');
}
Expand Down
4 changes: 1 addition & 3 deletions app/pages/admin/applications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ watchEffect(() => {
<span class="font-noto font-bold mr-2">
{{ postingsById[posting] || '' }}
</span>
<span class="bg-blue-100 px-2 py-1 border border-blue-300 rounded-lg text-blue-700 text-sm">
{{ applications[posting]?.length }} Applicants
</span>
<UiTag> {{ applications[posting]?.length }} Applicants </UiTag>
</div>
<div class="text-sm">
<AdminApplicationRow
Expand Down
7 changes: 5 additions & 2 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { data: postings } = await usePublicPostingsRepository();
const { data: careerSiteConfig } = useCareerSiteConfigObjectState();
const { data: seoConfig } = useSeoConfigObjectState();
const totalActivePostings = useTotalActivePostingsState();
const publicConfig = useRuntimeConfig().public;
let title: string = 'Careers'; // TODO: need better defaults (this will hardly be the case);
Expand Down Expand Up @@ -41,7 +41,10 @@ useSeoMeta({
<template>
<main class="grow w-full lg:w-2/3 mx-auto mt-20 p-2">
<SiteHeader />
<h3 class="text-lg leading-snug text-zinc-600 font-bold mt-8 mb-2">Open Positions</h3>
<h3 class="text-lg leading-snug text-zinc-600 font-bold mt-8 mb-2">
Open Positions
<UiTag>{{ totalActivePostings }}</UiTag>
</h3>
<div class="space-y-2" v-if="postings">
<PostingCard v-for="posting in postings" :key="posting.id" :posting="posting" />
</div>
Expand Down
12 changes: 7 additions & 5 deletions app/plugins/setup-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ export default defineNuxtPlugin(async () => {
const onboardingStatus = useOnboardingStatusState();
const careerSiteConfigObjectState = useCareerSiteConfigObjectState();
const seoConfigObjectState = useSeoConfigObjectState();
const totalActivePostings = useTotalActivePostingsState();

try {
const publicConfigRequest = await useFetch('/api/public/config');
if (!publicConfigRequest.data.value) {
throw new Error('config not received in response ' + publicConfigRequest.data.value);
}
const pubicConfig = publicConfigRequest.data.value;
const publicConfig = publicConfigRequest.data.value;

remoteAssetBase.value = pubicConfig.remoteAssetBase;
onboardingStatus.value = pubicConfig.onboardingStatus;
careerSiteConfigObjectState.setData(pubicConfig.settings.careerSite);
seoConfigObjectState.setData(pubicConfig.settings.seo);
remoteAssetBase.value = publicConfig.remoteAssetBase;
onboardingStatus.value = publicConfig.onboardingStatus;
totalActivePostings.value = publicConfig.totalActivePostings;
careerSiteConfigObjectState.setData(publicConfig.settings.careerSite);
seoConfigObjectState.setData(publicConfig.settings.seo);
} catch (error) {
console.error('error fetching remote-asset-config', error);
}
Expand Down
3 changes: 2 additions & 1 deletion server/api/public/config.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { CareerSiteConfig, SEOConfig } from '~~/shared/schemas/setting';
export default defineEventHandler(async () => {
const remoteAssetBase = (await general_memoryStorage.getItem('remoteAssetBase')) as string;
const onboardingStatus = !((await general_memoryStorage.getItem('firstSetupAccessKey')) as string);
const totalActivePostings = (await general_memoryStorage.getItem('totalActivePostings')) as number;

const settings = {
careerSite: {},
Expand All @@ -13,5 +14,5 @@ export default defineEventHandler(async () => {
settings.seo = (await settings_memoryStorage.getItem('seoConfig')) as SEOConfig;
settings.careerSite = (await settings_memoryStorage.getItem('careerSiteConfig')) as CareerSiteConfig;

return { remoteAssetBase, onboardingStatus, settings };
return { remoteAssetBase, onboardingStatus, totalActivePostings, settings };
});
11 changes: 10 additions & 1 deletion server/utils/tasks/seed-cache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { desc, inArray } from 'drizzle-orm';
import { desc, inArray, eq, count } from 'drizzle-orm';
import { jobPostingsTable, reviewTagsTable, metaDataTable } from '~~/server/db/schema';
import type { CareerSiteConfig, SEOConfig } from '~~/shared/schemas/setting';

Expand All @@ -20,6 +20,14 @@ export async function seedCache() {
totalApplicants: -1,
}));

const totalActivePostings =
(
await db
.select({ count: count(jobPostingsTable.id) })
.from(jobPostingsTable)
.where(eq(jobPostingsTable.isPublished, true))
)[0]?.count || 0;

const settings = {
careerSite: {},
seo: {},
Expand All @@ -44,6 +52,7 @@ export async function seedCache() {
general_memoryStorage.setItem('remoteAssetBase', remoteAssetBase),
general_memoryStorage.setItem('postings', jobPostings),
general_memoryStorage.setItem('reviewTags', reviewTags),
general_memoryStorage.setItem('totalActivePostings', totalActivePostings),
]);

return { result: true };
Expand Down

0 comments on commit e4d1512

Please sign in to comment.