Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
AVtheking committed Nov 26, 2023
1 parent 88c870f commit a120583
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 8 additions & 7 deletions controllers/course_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ const courseCtrl = {
if (!course) {
return next(new ErrorHandler(400, "No course found"));
}
await PopularSearch.findOneAndUpdate(
{
search: course.title,
},
{ $inc: { count: 1 } },
{ upsert: true }
);
const user = req.user;
const courseIdIndex = user.ownedCourse.findIndex((course) =>
course.courseId.equals(courseId)
Expand Down Expand Up @@ -349,13 +356,7 @@ const courseCtrl = {
const startIndex = (page - 1) * pageSize;

const searchquery = req.query.coursetitle;
await PopularSearch.findOneAndUpdate(
{
search: searchquery,
},
{ $inc: { count: 1 } },
{ upsert: true }
);

const result = await Course.aggregate([
{
$search: {
Expand Down
3 changes: 3 additions & 0 deletions controllers/payment_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const paymentCtrl = {
if (!course) {
return next(new ErrorHandler(400, "No course found"));
}
if (course.isPublished == false) {
return next(new ErrorHandler(400, "Course is not published"));
}
const courseIdIndex = user.ownedCourse.findIndex((course) =>
course.courseId.equals(courseId)
);
Expand Down

0 comments on commit a120583

Please sign in to comment.