Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

fix: Filter out resume with 2 sections or less

Khuram Niaz51076348cc2e
diff --git a/src/actions/profile.actions.ts b/src/actions/profile.actions.ts
index 2afb3c2..57bc7f6 100644
--- a/src/actions/profile.actions.ts
+++ b/src/actions/profile.actions.ts
@@ -23,6 +23,7 @@ import { writeFile } from "fs/promises";
export const getResumeList = async (
page: number = 1,
limit: number = APP_CONSTANTS.RECORDS_PER_PAGE,
+ minSections: number = 0,
): Promise<any | undefined> => {
try {
const user = await getCurrentUser();
@@ -31,15 +32,17 @@ export const getResumeList = async (
}
const skip = (page - 1) * limit;
- const [data, total] = await Promise.all([
+ // When filtering by section count, Prisma can't express ">= N related
+ // rows" in `where`, so fetch all of the user's resumes and filter in JS
+ // instead of applying skip/take.
+ const [rawData, total] = await Promise.all([
prisma.resume.findMany({
where: {
profile: {
userId: user.id,
},
},
- skip,
- take: limit,
+ ...(minSections > 0 ? {} : { skip, take: limit }),
select: {
id: true,
profileId: true,
@@ -50,6 +53,7 @@ export const getResumeList = async (
_count: {
select: {
Job: true,
+ ResumeSections: true,
},
},
},
@@ -65,6 +69,12 @@ export const getResumeList = async (
},
}),
]);
+
+ const data =
+ minSections > 0
+ ? rawData.filter((r) => r._count.ResumeSections >= minSections)
+ : rawData;
+
return { data, total, success: true };
} catch (error) {
const msg = "Failed to get resume list.";
diff --git a/src/app/dashboard/automations/page.tsx b/src/app/dashboard/automations/page.tsx
index fdabdd5..c8948ba 100644
--- a/src/app/dashboard/automations/page.tsx
+++ b/src/app/dashboard/automations/page.tsx
@@ -1,8 +1,13 @@
import { getResumeList } from "@/actions/profile.actions";
import { AutomationContainer } from "@/components/automations/AutomationContainer";
+import { APP_CONSTANTS } from "@/lib/constants";
export default async function AutomationsPage() {
- const resumeResult = await getResumeList(1, 100);
+ const resumeResult = await getResumeList(
+ 1,
+ 100,
+ APP_CONSTANTS.MIN_RESUME_SECTIONS_FOR_SELECTION,
+ );
const resumes =
resumeResult?.data?.map((r: { id: string; title: string }) => ({
id: r.id,
diff --git a/src/components/myjobs/AddJob.tsx b/src/components/myjobs/AddJob.tsx
index 2e353d5..038d7e6 100644
--- a/src/components/myjobs/AddJob.tsx
+++ b/src/components/myjobs/AddJob.tsx
@@ -50,6 +50,7 @@ import CreateResume from "../profile/CreateResume";
import { getResumeList } from "@/actions/profile.actions";
import { getCoverLetterList } from "@/actions/coverLetter.actions";
import { TagInput } from "./TagInput";
+import { APP_CONSTANTS } from "@/lib/constants";
type AddJobProps = {
jobStatuses: JobStatus[];
@@ -107,7 +108,11 @@ export function AddJob({
const loadResumes = useCallback(async () => {
try {
- const resumes = await getResumeList();
+ const resumes = await getResumeList(
+ 1,
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ APP_CONSTANTS.MIN_RESUME_SECTIONS_FOR_SELECTION,
+ );
setResumes(resumes.data);
} catch (error) {
console.error("Failed to load resumes:", error);
diff --git a/src/components/profile/AiJobMatchSection.tsx b/src/components/profile/AiJobMatchSection.tsx
index d8580a3..11754a9 100644
--- a/src/components/profile/AiJobMatchSection.tsx
+++ b/src/components/profile/AiJobMatchSection.tsx
@@ -2,6 +2,7 @@
import { getResumeList } from "@/actions/profile.actions";
import { saveJobMatchResult } from "@/actions/job.actions";
+import { APP_CONSTANTS } from "@/lib/constants";
import {
Sheet,
SheetClose,
@@ -118,7 +119,11 @@ export const AiJobMatchSection = ({
const getResumes = async () => {
try {
- const { data, success, message } = await getResumeList();
+ const { data, success, message } = await getResumeList(
+ 1,
+ APP_CONSTANTS.RECORDS_PER_PAGE,
+ APP_CONSTANTS.MIN_RESUME_SECTIONS_FOR_SELECTION,
+ );
if (!data || data.length === 0) {
return;
}
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 3fbdbd2..5abd2ac 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -20,6 +20,7 @@ export const APP_CONSTANTS = {
MAX_QUESTION_ANSWER_LENGTH: 5000,
MAX_SKILL_CATEGORIES: 8,
MAX_SKILLS_PER_CATEGORY: 20,
+ MIN_RESUME_SECTIONS_FOR_SELECTION: 2,
ACTIVITY_MAX_DURATION_MINUTES: 8 * 60, // 8 Hours
ACTIVITY_MAX_DURATION_MS: 8 * 60 * 60 * 1000, // 8 hours in milliseconds
RECENT_NUM_JOBS_ACTIVITIES: 7,