Skip to content

Commit

Permalink
Fix add code to update loggedusermodel (#156)
Browse files Browse the repository at this point in the history
* Fix add code to update loggedusermodel

* add fix for blog seeds
  • Loading branch information
Mugisha146 authored Nov 22, 2024
1 parent fa2bf88 commit 2223abf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/resolvers/applicationStageResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,28 @@ export const applicationStageResolvers: any = {
},
}
);

const updatedApplicant = await TraineeApplicant.findOne({
_id: applicantId,
})
.populate("email")
.lean();

const email = updatedApplicant?.email;

if (email) {
await LoggedUserModel.updateOne(
{ email },
{
$set: {
applicationPhase: nextStage,
status: "Admitted",
role: traineeRole._id,
},
}
);
} else {
throw new Error("Email not found for the provided applicant ID");
}
const notification2 = await ApplicantNotificationsModel.create({
userId: user!._id,
message,
Expand Down
15 changes: 15 additions & 0 deletions src/seeders/blogs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { BlogModel } from "../models/blogModel";
import { CommentModel } from "../models/commentModel";
import { LikeModel } from "../models/likeModel";
import { CommentLikeModel } from "../models/commentLike";
import { CommentReplyModel } from "../models/CommentReply";

const seedBlogs = async () => {
await BlogModel.deleteMany({});
await CommentModel.deleteMany({});
await CommentLikeModel.deleteMany({});
await LikeModel.deleteMany({});
await CommentReplyModel.deleteMany({});
};

export default seedBlogs;
2 changes: 2 additions & 0 deletions src/seeders/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { connect } from '../database/db.config'
import seedBlogs from "./blogs";

import seedDeleteTrainee from './DelTrainee';
import seedJobs from './jobs';
Expand All @@ -16,5 +17,6 @@ connect().then(async () => {
await seedCohorts();
await seedJobs();
await seedApplications();
await seedBlogs();
process.exit()
})

0 comments on commit 2223abf

Please sign in to comment.