abmp-npm 2.0.6 → 2.0.9
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/backend/consts.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const PAC_API_URL = 'https://members.abmp.com/eweb/api/Wix';
|
|
2
|
+
const BACKUP_API_URL = 'https://psdevteamenterpris.wixstudio.com/abmp-backup/_functions';
|
|
2
3
|
const SSO_TOKEN_AUTH_API_URL = 'https://members.professionalassistcorp.com/';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -40,4 +41,5 @@ module.exports = {
|
|
|
40
41
|
COMPILED_FILTERS_FIELDS,
|
|
41
42
|
MEMBERSHIPS_TYPES,
|
|
42
43
|
SSO_TOKEN_AUTH_API_URL,
|
|
44
|
+
BACKUP_API_URL,
|
|
43
45
|
};
|
|
@@ -12,7 +12,7 @@ const wixData = {
|
|
|
12
12
|
get: auth.elevate(items.get),
|
|
13
13
|
truncate: auth.elevate(items.truncate),
|
|
14
14
|
bulkSave: auth.elevate(items.bulkSave),
|
|
15
|
+
search: auth.elevate(items.search),
|
|
15
16
|
//TODO: add other methods here as needed
|
|
16
17
|
};
|
|
17
|
-
|
|
18
18
|
module.exports = { wixData };
|
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
normalizeUrlForComparison,
|
|
11
11
|
queryAllItems,
|
|
12
12
|
generateGeoHash,
|
|
13
|
+
searchAllItems,
|
|
13
14
|
} = require('./utils');
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -121,7 +122,7 @@ async function getMemberBySlug({
|
|
|
121
122
|
if (!slug) return null;
|
|
122
123
|
|
|
123
124
|
try {
|
|
124
|
-
let query = wixData.
|
|
125
|
+
let query = wixData.search(COLLECTIONS.MEMBERS_DATA).expression(slug);
|
|
125
126
|
|
|
126
127
|
if (excludeDropped) {
|
|
127
128
|
query = query.ne('action', 'drop');
|
|
@@ -131,7 +132,8 @@ async function getMemberBySlug({
|
|
|
131
132
|
query = query.ne('memberId', memberId);
|
|
132
133
|
}
|
|
133
134
|
query = query.limit(1000);
|
|
134
|
-
const
|
|
135
|
+
const searchResult = await searchAllItems(query);
|
|
136
|
+
const membersList = searchResult.filter(item => item.url && item.url.includes(slug)); //replacement for contains
|
|
135
137
|
let matchingMembers = membersList.filter(
|
|
136
138
|
item => item.url && item.url.toLowerCase() === slug.toLowerCase()
|
|
137
139
|
);
|
package/backend/utils.js
CHANGED
|
@@ -107,18 +107,28 @@ function getAddressesByStatus(addresses = [], addressDisplayOption = []) {
|
|
|
107
107
|
})
|
|
108
108
|
.filter(Boolean);
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
let oldResults = await query.find();
|
|
110
|
+
const getAllItems = async querySearchResult => {
|
|
111
|
+
let oldResults = querySearchResult;
|
|
113
112
|
console.log(`found items: ${oldResults.items.length}`);
|
|
114
113
|
const allItems = oldResults.items;
|
|
115
114
|
while (oldResults.hasNext()) {
|
|
116
115
|
oldResults = await oldResults.next();
|
|
117
116
|
allItems.push(...oldResults.items);
|
|
118
117
|
}
|
|
119
|
-
console.log(`all items: ${allItems.length}`);
|
|
118
|
+
console.log(`all items count : ${allItems.length}`);
|
|
120
119
|
return allItems;
|
|
121
120
|
};
|
|
121
|
+
const searchAllItems = async searchQuery => {
|
|
122
|
+
console.log('start search');
|
|
123
|
+
const searchResults = await searchQuery.run();
|
|
124
|
+
return getAllItems(searchResults);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const queryAllItems = async query => {
|
|
128
|
+
console.log('start query');
|
|
129
|
+
const queryResults = await query.find();
|
|
130
|
+
return getAllItems(queryResults);
|
|
131
|
+
};
|
|
122
132
|
/**
|
|
123
133
|
* Chunks large arrays into smaller chunks for processing
|
|
124
134
|
* @param {Array} array - Array to chunk
|
|
@@ -206,4 +216,5 @@ module.exports = {
|
|
|
206
216
|
formatDateOnly,
|
|
207
217
|
getAddressesByStatus,
|
|
208
218
|
isPAC_STAFF,
|
|
219
|
+
searchAllItems,
|
|
209
220
|
};
|