@kipicore/dbcore 1.1.218 → 1.1.219

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,8 +64,9 @@ class TestimonialModel extends sequelize_1.Model {
64
64
  static addHooks(models) {
65
65
  const { InstituteModel, UserModel, InstituteEntityModel } = models;
66
66
  const beforeCreateOrUpdateHook = async (testimonial) => {
67
+ let institute = null;
67
68
  if (testimonial.instituteId) {
68
- const institute = await InstituteModel.findByPk(testimonial.instituteId);
69
+ institute = await InstituteModel.findByPk(testimonial.instituteId);
69
70
  if (!institute) {
70
71
  throw new Error(errorMessages_1.INSTITUTE_ERROR_MESSAGES.NOT_FOUND);
71
72
  }
@@ -80,11 +81,18 @@ class TestimonialModel extends sequelize_1.Model {
80
81
  }
81
82
  testimonial.class = `${(0, utils_1.fromSnakeCaseToNormalText)(testimonial.userType)}`;
82
83
  if (testimonial.userId && testimonial.instituteId && testimonial.userType !== app_1.USER_TYPES.PARENTS) {
83
- const meta = await userInstituteMetaModel_1.default.findOne({
84
+ const userInstituteMetaWhere = {
84
85
  userId: testimonial.userId,
85
86
  instituteId: testimonial.instituteId,
86
- status: app_1.USER_INSTITUTE_META_STATUS.ACCEPTED,
87
- });
87
+ status: { $in: [app_1.USER_INSTITUTE_META_STATUS.ACCEPTED] },
88
+ };
89
+ if (testimonial.academicCalendarId)
90
+ userInstituteMetaWhere.academicCalendarId = testimonial.academicCalendarId;
91
+ if (institute?.type !== null || institute?.subType !== null) {
92
+ userInstituteMetaWhere.status = { $in: [app_1.USER_INSTITUTE_META_STATUS.ACCEPTED, app_1.USER_INSTITUTE_META_STATUS.PENDING] };
93
+ // userInstituteMetaWhere.details = BOOLEAN_STATUS.YES;
94
+ }
95
+ const meta = await userInstituteMetaModel_1.default.findOne(userInstituteMetaWhere);
88
96
  if (!meta) {
89
97
  throw new Error(errorMessages_1.USER_INSTITUTE_META_ERROR_MESSAGES.NOT_FOUND);
90
98
  }
@@ -97,10 +105,7 @@ class TestimonialModel extends sequelize_1.Model {
97
105
  association: 'entityType',
98
106
  required: true,
99
107
  where: {
100
- [sequelize_1.Op.or]: [
101
- { title: { [sequelize_1.Op.iLike]: 'STANDARD' } },
102
- { title: { [sequelize_1.Op.iLike]: 'MEDIUM' } },
103
- ],
108
+ [sequelize_1.Op.or]: [{ title: { [sequelize_1.Op.iLike]: 'STANDARD' } }, { title: { [sequelize_1.Op.iLike]: 'MEDIUM' } }],
104
109
  },
105
110
  },
106
111
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.218",
3
+ "version": "1.1.219",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",