shuttlepro-shared 1.2.32 → 1.2.34

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.
@@ -1,5 +1,8 @@
1
1
  const { UserRole } = require("../../models/UserRole");
2
- const { getRedisData, addDataToRedisSet } = require("../../config/redis");
2
+ const {
3
+ getDataFromRedisSet,
4
+ addDataToRedisSet,
5
+ } = require("../../config/redis");
3
6
 
4
7
  const defaultSelect =
5
8
  "iconUrl thumbUrl name productsCount ordersCount contact email address websiteUrl facebookUrl twitterUrl instagramUrl members defaultModule";
@@ -20,7 +23,7 @@ const getCachedMembers = async (filter = {}) => {
20
23
  ? `${CACHE_KEY_ALL_MEMBERS}_${JSON.stringify(filter)}`
21
24
  : CACHE_KEY_ALL_MEMBERS;
22
25
 
23
- let members = await getRedisData(cacheKey);
26
+ let members = await getDataFromRedisSet(cacheKey);
24
27
 
25
28
  if (!members) {
26
29
  members = await UserRole.find(filter)
@@ -120,12 +123,8 @@ const deleteUserRole = async (id) => {
120
123
 
121
124
  const findUserWorkspaces = async (userId) => {
122
125
  const cacheKey = `${CACHE_KEY_USER_WORKSPACE_PREFIX}${userId}`;
123
- console.log(cacheKey, "cacheKey");
124
- let userRoleWithWorkspaces = await getRedisData(cacheKey);
125
-
126
- console.log(userRoleWithWorkspaces, "userRoleWithWorkspaces");
127
-
128
- if (!userRoleWithWorkspaces) {
126
+ let userRoleWithWorkspaces = await getDataFromRedisSet(cacheKey);
127
+ if (!userRoleWithWorkspaces.length) {
129
128
  userRoleWithWorkspaces = await UserRole.find({
130
129
  userId: userId,
131
130
  })
@@ -147,7 +146,6 @@ const findUserWorkspaces = async (userId) => {
147
146
  await addDataToRedisSet(cacheKey, userRoleWithWorkspaces);
148
147
  }
149
148
  }
150
-
151
149
  return userRoleWithWorkspaces;
152
150
  };
153
151
 
package/config/redis.js CHANGED
@@ -107,6 +107,7 @@ const getDataFromRedisSet = async (key) => {
107
107
  try {
108
108
  await connectRedis();
109
109
  const values = await client.sMembers(key);
110
+ console.log(values, "values");
110
111
  return values; // returns an array of values
111
112
  } catch (err) {
112
113
  console.error("Redis Error:", err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.2.32",
3
+ "version": "1.2.34",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {