Skip to content

Commit

Permalink
fix: deleted jobs were showing
Browse files Browse the repository at this point in the history
  • Loading branch information
Paribesh01 committed Oct 21, 2024
1 parent b195ae9 commit 4f18395
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
18 changes: 18 additions & 0 deletions prisma/migrations/20241021191938_somfadf/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- CreateEnum
CREATE TYPE "ProjectStack" AS ENUM ('GO', 'PYTHON', 'MERN', 'NEXTJS', 'AI_GPT_APIS', 'SPRINGBOOT', 'OTHERS');

-- DropForeignKey
ALTER TABLE "Experience" DROP CONSTRAINT "Experience_userId_fkey";

-- DropForeignKey
ALTER TABLE "Project" DROP CONSTRAINT "Project_userId_fkey";

-- AlterTable
ALTER TABLE "Project" ADD COLUMN "projectThumbnail" TEXT,
ADD COLUMN "stack" "ProjectStack" NOT NULL DEFAULT 'OTHERS';

-- AddForeignKey
ALTER TABLE "Experience" ADD CONSTRAINT "Experience_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Project" ADD CONSTRAINT "Project_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
14 changes: 13 additions & 1 deletion prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const prisma = new PrismaClient();

const users = [
{ id: '1', name: 'Jack', email: '[email protected]' },
{ id: '2', name: 'Admin', email: '[email protected]', role: Role.ADMIN , onBoard : true },
{ id: '2', name: 'Admin', email: '[email protected]', role: Role.ADMIN, onBoard: true },
{ id: '3', name: 'Hr', email: '[email protected]', role: Role.HR },
];

Expand Down Expand Up @@ -63,6 +63,7 @@ let jobs = [
minSalary: null,
maxSalary: null,
isVerifiedJob: false,

},
{
id: '3',
Expand All @@ -86,6 +87,7 @@ let jobs = [
minSalary: 90000,
maxSalary: 120000,
isVerifiedJob: true,
deleted: true
},
{
id: '4',
Expand Down Expand Up @@ -134,6 +136,7 @@ let jobs = [
minSalary: 110000,
maxSalary: 150000,
isVerifiedJob: true,
deleted: true
},
{
id: '6',
Expand All @@ -159,6 +162,7 @@ let jobs = [
minSalary: 80000,
maxSalary: 100000,
isVerifiedJob: false,

},
{
id: '7',
Expand All @@ -183,6 +187,8 @@ let jobs = [
minSalary: 70000,
maxSalary: 90000,
isVerifiedJob: false,
delted: true

},
{
id: '8',
Expand All @@ -207,6 +213,8 @@ let jobs = [
minSalary: null,
maxSalary: null,
isVerifiedJob: true,
deleted: true

},
{
id: '9',
Expand All @@ -229,6 +237,7 @@ let jobs = [
minSalary: 100000,
maxSalary: 130000,
isVerifiedJob: true,

},
{
id: '10',
Expand All @@ -253,6 +262,7 @@ let jobs = [
minSalary: 75000,
maxSalary: 95000,
isVerifiedJob: false,

},
{
id: '11',
Expand All @@ -274,6 +284,7 @@ let jobs = [
minSalary: 25000,
maxSalary: 50000,
isVerifiedJob: true,

},
{
id: '12',
Expand All @@ -298,6 +309,7 @@ let jobs = [
minSalary: null,
maxSalary: null,
isVerifiedJob: true,
delted: false
},
];

Expand Down
12 changes: 10 additions & 2 deletions src/actions/job.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const getAllJobs = withSession<
? { ...filterQueries }
: {
isVerifiedJob: true,
deleted: false,
...filterQueries,
expired: false,
}),
Expand Down Expand Up @@ -195,6 +196,7 @@ export const getRecommendedJobs = withServerActionAsyncCatcher<
id: { not: id },
isVerifiedJob: true,
expired: false,
deleted: false,
},
orderBy: {
postedAt: 'desc',
Expand Down Expand Up @@ -227,6 +229,7 @@ export const getRecommendedJobs = withServerActionAsyncCatcher<
where: {
id: { not: id },
expired: false,
deleted: false,
},
orderBy: {
postedAt: 'desc',
Expand Down Expand Up @@ -273,7 +276,7 @@ export const getJobById = withServerActionAsyncCatcher<
const result = JobByIdSchema.parse(data);
const { id } = result;
const job = await prisma.job.findFirst({
where: { id, expired: false },
where: { id, expired: false, deleted: false },
select: {
id: true,
title: true,
Expand Down Expand Up @@ -308,8 +311,12 @@ export const getJobById = withServerActionAsyncCatcher<

export const getCityFilters = async () => {
const response = await prisma.job.findMany({
select: {
where: {
isVerifiedJob: true,
expired: false,
deleted: false,
},
select: {
city: true,
},
});
Expand All @@ -324,6 +331,7 @@ export const getRecentJobs = async () => {
const recentJobs = await prisma.job.findMany({
where: {
isVerifiedJob: true,
deleted: false,
expired: false,
},
orderBy: {
Expand Down

0 comments on commit 4f18395

Please sign in to comment.