@plusscommunities/pluss-maintenance-aws-forms 2.1.43 → 2.1.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-maintenance-aws-forms",
3
- "version": "2.1.43",
3
+ "version": "2.1.44",
4
4
  "description": "Extension package to enable maintenance on Pluss Communities Platform",
5
5
  "scripts": {
6
6
  "gc": "node ../../tools/gc ./",
@@ -23,7 +23,14 @@ const normalizePriority = (priority) =>
23
23
  // Because DynamoDB pages are unfiltered and we filter after query,
24
24
  // a single page may yield very few matching results. We keep
25
25
  // fetching pages until we have this many items to return.
26
- const MIN_RESULT_COUNT = 50;
26
+ const MIN_RESULT_COUNT = 250;
27
+
28
+ // When filters are active, fetch all matching results so the
29
+ // client receives a complete set rather than a truncated page.
30
+ const MIN_RESULT_COUNT_FILTERED = Infinity;
31
+
32
+ const hasActiveFilters = (qParams) =>
33
+ qParams.status || qParams.priority || qParams.type || qParams.search || qParams.startTime || qParams.endTime;
27
34
 
28
35
  /**
29
36
  * Apply all post-query filters to a set of jobs.
@@ -152,8 +159,10 @@ module.exports = async (event) => {
152
159
  log("getRequests", "LastEvaluatedKey", lastKey, logId);
153
160
  log("getRequests", "FirstPageFiltered", allJobs.length, logId);
154
161
 
155
- // auto-fill: keep fetching pages until we have MIN_RESULT_COUNT filtered results
156
- while (lastKey && allJobs.length < MIN_RESULT_COUNT) {
162
+ const minResults = hasActiveFilters(qParams) ? MIN_RESULT_COUNT_FILTERED : MIN_RESULT_COUNT;
163
+
164
+ // auto-fill: keep fetching pages until we have enough filtered results
165
+ while (lastKey && allJobs.length < minResults) {
157
166
  const nextQuery = { ...query, ExclusiveStartKey: lastKey };
158
167
  result = await indexQuery(values.tableNameMaintenance, nextQuery);
159
168
  const filtered = filterJobs(result.Items, qParams, authorised, assigneeTracking, userId);