@sera4/essentia 1.1.50 → 1.1.52

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": "@sera4/essentia",
3
- "version": "1.1.50",
3
+ "version": "1.1.52",
4
4
  "description": "A library of utilities for Teleporte Web Services",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/package.tar.gz CHANGED
Binary file
@@ -113,6 +113,13 @@ class SequelizePaginator {
113
113
  const getPaginationData = (result) => {
114
114
  var currentPage = this.zeroBasedOffset ? pagination.offset : pagination.offset + 1;
115
115
  var outOfBounds = result.rows.length === 0;
116
+
117
+ // For queries with aggregation (Group By, Count), sequelize findAndCountAll returns an array of objects instead of just an integer
118
+ // To avoid implementing a custom findAndCountAll, we just use the array's Length
119
+ if (Array.isArray(result.count)) {
120
+ result.count = result.count.length;
121
+ }
122
+
116
123
  var totalPages = Math.ceil(result.count / pagination.limit);
117
124
  var data = {};
118
125
  data[this.paginateOut["current_page"]] = currentPage;
package/utils/index.js CHANGED
@@ -64,8 +64,11 @@ export const utils = {
64
64
 
65
65
  return routeType;
66
66
  },
67
- isWebRoute: (sessionType) => (sessionType === TWS_ROUTE_TYPES['web']),
68
- isApiRoute: (sessionType) => (sessionType === TWS_ROUTE_TYPES['api']),
69
- isMobileRoute: (sessionType) => (sessionType === TWS_ROUTE_TYPES['mobile']),
70
- isOtherRoute: (sessionType) => (sessionType === TWS_ROUTE_TYPES['other'])
67
+ isWebRoute: (sessionType) => (parseInt(sessionType) === TWS_ROUTE_TYPES['web']),
68
+ isApiRoute: (sessionType) => (parseInt(sessionType) === TWS_ROUTE_TYPES['api']),
69
+ isMobileRoute: (sessionType) => (parseInt(sessionType) === TWS_ROUTE_TYPES['mobile']),
70
+ isOtherRoute: (sessionType) => {
71
+ const value = parseInt(sessionType);
72
+ return ((value === TWS_ROUTE_TYPES['other']) || isNaN(value)) ? true : false;
73
+ }
71
74
  }