|
|
@ -1,5 +1,8 @@
|
|
|
|
import { z } from 'zod';
|
|
|
|
import { z } from 'zod';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import type { FilterCounts } from '~/utils/resumes/resumeFilters';
|
|
|
|
|
|
|
|
import { resumeGetFilterCounts } from '~/utils/resumes/resumeGetFilterCounts';
|
|
|
|
|
|
|
|
|
|
|
|
import { createProtectedRouter } from '../context';
|
|
|
|
import { createProtectedRouter } from '../context';
|
|
|
|
|
|
|
|
|
|
|
|
import type { Resume } from '~/types/resume';
|
|
|
|
import type { Resume } from '~/types/resume';
|
|
|
@ -63,6 +66,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
.query('findUserStarred', {
|
|
|
|
.query('findUserStarred', {
|
|
|
|
input: z.object({
|
|
|
|
input: z.object({
|
|
|
|
experienceFilters: z.string().array(),
|
|
|
|
experienceFilters: z.string().array(),
|
|
|
|
|
|
|
|
isTop10: z.boolean(),
|
|
|
|
isUnreviewed: z.boolean(),
|
|
|
|
isUnreviewed: z.boolean(),
|
|
|
|
locationFilters: z.string().array(),
|
|
|
|
locationFilters: z.string().array(),
|
|
|
|
roleFilters: z.string().array(),
|
|
|
|
roleFilters: z.string().array(),
|
|
|
@ -78,23 +82,16 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
locationFilters,
|
|
|
|
locationFilters,
|
|
|
|
experienceFilters,
|
|
|
|
experienceFilters,
|
|
|
|
searchValue,
|
|
|
|
searchValue,
|
|
|
|
|
|
|
|
isTop10,
|
|
|
|
sortOrder,
|
|
|
|
sortOrder,
|
|
|
|
isUnreviewed,
|
|
|
|
isUnreviewed,
|
|
|
|
skip,
|
|
|
|
skip,
|
|
|
|
take,
|
|
|
|
take,
|
|
|
|
} = input;
|
|
|
|
} = input;
|
|
|
|
const totalRecords = await ctx.prisma.resumesStar.count({
|
|
|
|
|
|
|
|
where: {
|
|
|
|
let totalRecords = 10;
|
|
|
|
resume: {
|
|
|
|
let filterCounts = {} as FilterCounts;
|
|
|
|
experience: { in: experienceFilters },
|
|
|
|
|
|
|
|
isResolved: isUnreviewed ? false : {},
|
|
|
|
|
|
|
|
locationId: { in: locationFilters },
|
|
|
|
|
|
|
|
role: { in: roleFilters },
|
|
|
|
|
|
|
|
title: { contains: searchValue, mode: 'insensitive' },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
userId,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const resumeStarsData = await ctx.prisma.resumesStar.findMany({
|
|
|
|
const resumeStarsData = await ctx.prisma.resumesStar.findMany({
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
resume: {
|
|
|
|
resume: {
|
|
|
@ -140,7 +137,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
skip,
|
|
|
|
skip: isTop10 ? 0 : skip,
|
|
|
|
take,
|
|
|
|
take,
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
|
resume: {
|
|
|
|
resume: {
|
|
|
@ -174,6 +171,22 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
return resume;
|
|
|
|
return resume;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isTop10) {
|
|
|
|
|
|
|
|
filterCounts = resumeGetFilterCounts(mappedResumeData);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
totalRecords = await ctx.prisma.resumesStar.count({
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
resume: {
|
|
|
|
|
|
|
|
experience: { in: experienceFilters },
|
|
|
|
|
|
|
|
isResolved: isUnreviewed ? false : {},
|
|
|
|
|
|
|
|
locationId: { in: locationFilters },
|
|
|
|
|
|
|
|
role: { in: roleFilters },
|
|
|
|
|
|
|
|
title: { contains: searchValue, mode: 'insensitive' },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
userId,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const roleCounts = await ctx.prisma.resumesResume.groupBy({
|
|
|
|
const roleCounts = await ctx.prisma.resumesResume.groupBy({
|
|
|
|
_count: {
|
|
|
|
_count: {
|
|
|
|
_all: true,
|
|
|
|
_all: true,
|
|
|
@ -237,11 +250,12 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
locationCounts.map((lc) => [lc.locationId, lc._count._all]),
|
|
|
|
locationCounts.map((lc) => [lc.locationId, lc._count._all]),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const filterCounts = {
|
|
|
|
filterCounts = {
|
|
|
|
experience: mappedExperienceCounts,
|
|
|
|
experience: mappedExperienceCounts,
|
|
|
|
location: mappedLocationCounts,
|
|
|
|
location: mappedLocationCounts,
|
|
|
|
role: mappedRoleCounts,
|
|
|
|
role: mappedRoleCounts,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return { filterCounts, mappedResumeData, totalRecords };
|
|
|
|
return { filterCounts, mappedResumeData, totalRecords };
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -249,6 +263,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
.query('findUserCreated', {
|
|
|
|
.query('findUserCreated', {
|
|
|
|
input: z.object({
|
|
|
|
input: z.object({
|
|
|
|
experienceFilters: z.string().array(),
|
|
|
|
experienceFilters: z.string().array(),
|
|
|
|
|
|
|
|
isTop10: z.boolean(),
|
|
|
|
isUnreviewed: z.boolean(),
|
|
|
|
isUnreviewed: z.boolean(),
|
|
|
|
locationFilters: z.string().array(),
|
|
|
|
locationFilters: z.string().array(),
|
|
|
|
roleFilters: z.string().array(),
|
|
|
|
roleFilters: z.string().array(),
|
|
|
@ -265,20 +280,15 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
experienceFilters,
|
|
|
|
experienceFilters,
|
|
|
|
sortOrder,
|
|
|
|
sortOrder,
|
|
|
|
searchValue,
|
|
|
|
searchValue,
|
|
|
|
|
|
|
|
isTop10,
|
|
|
|
isUnreviewed,
|
|
|
|
isUnreviewed,
|
|
|
|
take,
|
|
|
|
take,
|
|
|
|
skip,
|
|
|
|
skip,
|
|
|
|
} = input;
|
|
|
|
} = input;
|
|
|
|
const totalRecords = await ctx.prisma.resumesResume.count({
|
|
|
|
|
|
|
|
where: {
|
|
|
|
let totalRecords = 10;
|
|
|
|
experience: { in: experienceFilters },
|
|
|
|
let filterCounts = {} as FilterCounts;
|
|
|
|
isResolved: isUnreviewed ? false : {},
|
|
|
|
|
|
|
|
locationId: { in: locationFilters },
|
|
|
|
|
|
|
|
role: { in: roleFilters },
|
|
|
|
|
|
|
|
title: { contains: searchValue, mode: 'insensitive' },
|
|
|
|
|
|
|
|
userId,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const resumesData = await ctx.prisma.resumesResume.findMany({
|
|
|
|
const resumesData = await ctx.prisma.resumesResume.findMany({
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
_count: {
|
|
|
|
_count: {
|
|
|
@ -315,7 +325,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
: { comments: { _count: 'desc' } },
|
|
|
|
: { comments: { _count: 'desc' } },
|
|
|
|
skip,
|
|
|
|
skip: isTop10 ? 0 : skip,
|
|
|
|
take,
|
|
|
|
take,
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
|
experience: { in: experienceFilters },
|
|
|
|
experience: { in: experienceFilters },
|
|
|
@ -346,6 +356,20 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
return resume;
|
|
|
|
return resume;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isTop10) {
|
|
|
|
|
|
|
|
filterCounts = resumeGetFilterCounts(mappedResumeData);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
totalRecords = await ctx.prisma.resumesResume.count({
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
experience: { in: experienceFilters },
|
|
|
|
|
|
|
|
isResolved: isUnreviewed ? false : {},
|
|
|
|
|
|
|
|
locationId: { in: locationFilters },
|
|
|
|
|
|
|
|
role: { in: roleFilters },
|
|
|
|
|
|
|
|
title: { contains: searchValue, mode: 'insensitive' },
|
|
|
|
|
|
|
|
userId,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const roleCounts = await ctx.prisma.resumesResume.groupBy({
|
|
|
|
const roleCounts = await ctx.prisma.resumesResume.groupBy({
|
|
|
|
_count: {
|
|
|
|
_count: {
|
|
|
|
_all: true,
|
|
|
|
_all: true,
|
|
|
@ -397,11 +421,12 @@ export const resumesResumeUserRouter = createProtectedRouter()
|
|
|
|
locationCounts.map((lc) => [lc.locationId, lc._count._all]),
|
|
|
|
locationCounts.map((lc) => [lc.locationId, lc._count._all]),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const filterCounts = {
|
|
|
|
filterCounts = {
|
|
|
|
experience: mappedExperienceCounts,
|
|
|
|
experience: mappedExperienceCounts,
|
|
|
|
location: mappedLocationCounts,
|
|
|
|
location: mappedLocationCounts,
|
|
|
|
role: mappedRoleCounts,
|
|
|
|
role: mappedRoleCounts,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return { filterCounts, mappedResumeData, totalRecords };
|
|
|
|
return { filterCounts, mappedResumeData, totalRecords };
|
|
|
|
},
|
|
|
|
},
|
|
|
|