@eeplatform/basic-edu 1.4.2 → 1.4.3

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.
package/dist/index.mjs CHANGED
@@ -2078,24 +2078,41 @@ function useEnrollmentRepo() {
2078
2078
  status = "active",
2079
2079
  school = "",
2080
2080
  schoolYear = "",
2081
- gradeLevelToEnroll = ""
2081
+ gradeLevelToEnroll = "",
2082
+ createdBy = ""
2082
2083
  } = {}) {
2083
2084
  page = page > 0 ? page - 1 : 0;
2084
2085
  const query = {
2085
2086
  status
2086
2087
  };
2088
+ const cacheParams = {
2089
+ page,
2090
+ limit,
2091
+ sort: JSON.stringify(sort)
2092
+ };
2093
+ if (createdBy) {
2094
+ try {
2095
+ query.createdBy = new ObjectId4(createdBy);
2096
+ cacheParams.createdBy = createdBy;
2097
+ } catch (error) {
2098
+ throw new BadRequestError5("Invalid createdBy ID.");
2099
+ }
2100
+ }
2087
2101
  if (school) {
2088
2102
  try {
2089
2103
  query.school = new ObjectId4(school);
2104
+ cacheParams.school = school;
2090
2105
  } catch (error) {
2091
2106
  throw new BadRequestError5("Invalid school ID.");
2092
2107
  }
2093
2108
  }
2094
2109
  if (schoolYear) {
2095
2110
  query.schoolYear = schoolYear;
2111
+ cacheParams.schoolYear = schoolYear;
2096
2112
  }
2097
2113
  if (gradeLevelToEnroll) {
2098
2114
  query.gradeLevelToEnroll = gradeLevelToEnroll;
2115
+ cacheParams.gradeLevelToEnroll = gradeLevelToEnroll;
2099
2116
  }
2100
2117
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
2101
2118
  if (search) {
@@ -2107,11 +2124,6 @@ function useEnrollmentRepo() {
2107
2124
  { gradeLevelToEnroll: { $regex: search, $options: "i" } }
2108
2125
  ];
2109
2126
  }
2110
- const cacheParams = {
2111
- page,
2112
- limit,
2113
- sort: JSON.stringify(sort)
2114
- };
2115
2127
  if (search)
2116
2128
  cacheParams.search = search;
2117
2129
  if (status !== "active")
@@ -3031,7 +3043,8 @@ function useEnrollmentController() {
3031
3043
  status: Joi7.string().optional().allow("", null),
3032
3044
  school: Joi7.string().hex().optional().allow("", null),
3033
3045
  schoolYear: Joi7.string().optional().allow("", null),
3034
- gradeLevelToEnroll: Joi7.string().optional().allow("", null)
3046
+ gradeLevelToEnroll: Joi7.string().optional().allow("", null),
3047
+ createdBy: Joi7.string().hex().optional().allow("", null)
3035
3048
  });
3036
3049
  const { error } = validation.validate(query);
3037
3050
  if (error) {
@@ -3043,6 +3056,7 @@ function useEnrollmentController() {
3043
3056
  limit = isNaN(limit) ? 20 : limit;
3044
3057
  const sort = req.query.sort ? String(req.query.sort).split(",") : "";
3045
3058
  const sortOrder = req.query.sortOrder ? String(req.query.sortOrder).split(",") : "";
3059
+ const createdBy = req.query.createdBy ?? "";
3046
3060
  const sortObj = {};
3047
3061
  if (sort && sort.length > 0 && sortOrder && sortOrder.length > 0 && sort.length === sortOrder.length) {
3048
3062
  for (let i = 0; i < sort.length; i++) {
@@ -3059,7 +3073,8 @@ function useEnrollmentController() {
3059
3073
  status: req.query.status,
3060
3074
  school: req.query.school,
3061
3075
  schoolYear: req.query.schoolYear,
3062
- gradeLevelToEnroll: req.query.gradeLevelToEnroll
3076
+ gradeLevelToEnroll: req.query.gradeLevelToEnroll,
3077
+ createdBy
3063
3078
  });
3064
3079
  res.json(result);
3065
3080
  return;