abmp-npm 1.10.12 → 1.10.13
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/routers/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { getMainAddress } = require('../../public/Utils/sharedUtils');
|
|
2
2
|
const { getMemberBySlug } = require('../members-data-methods');
|
|
3
3
|
const {
|
|
4
|
-
|
|
4
|
+
getMoreAddressesToDisplay,
|
|
5
5
|
formatDateToMonthYear,
|
|
6
6
|
hasStudentMembership,
|
|
7
7
|
isPAC_STAFF,
|
|
@@ -48,7 +48,10 @@ function transformMemberToProfileData(member, siteAssociation) {
|
|
|
48
48
|
?.map(val => val.license)
|
|
49
49
|
.filter(Boolean)
|
|
50
50
|
.join(', ');
|
|
51
|
-
const
|
|
51
|
+
const moreAddressesToDisplay = getMoreAddressesToDisplay(
|
|
52
|
+
member.addresses,
|
|
53
|
+
member.addressDisplayOption
|
|
54
|
+
);
|
|
52
55
|
|
|
53
56
|
const memberships = member.memberships || [];
|
|
54
57
|
const siteAssociationMembership = memberships.find(m => m.association === siteAssociation);
|
|
@@ -67,7 +70,7 @@ function transformMemberToProfileData(member, siteAssociation) {
|
|
|
67
70
|
mainAddress,
|
|
68
71
|
testimonials: member.testimonial || [],
|
|
69
72
|
licenceNo,
|
|
70
|
-
|
|
73
|
+
moreAddressesToDisplay,
|
|
71
74
|
memberSince:
|
|
72
75
|
(member.showABMP &&
|
|
73
76
|
siteAssociationMembership &&
|
|
@@ -9,7 +9,8 @@ const { queryAllItems, chunkArray } = require('../utils');
|
|
|
9
9
|
const { TASKS_NAMES } = require('./consts');
|
|
10
10
|
|
|
11
11
|
const COLLECTION_WITH_URLS = 'MembersDataWithUrls';
|
|
12
|
-
const CHUNK_SIZE = 5000; // 5k members per task
|
|
12
|
+
const CHUNK_SIZE = 5000; // 5k members per task for migration
|
|
13
|
+
const GENERATION_CHUNK_SIZE = 1000; // 1k members per task for URL generation
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Step 1: Migrate existing URLs from backup collection
|
|
@@ -201,7 +202,7 @@ async function scheduleGenerateMissingUrls() {
|
|
|
201
202
|
};
|
|
202
203
|
}
|
|
203
204
|
|
|
204
|
-
const chunks = chunkArray(membersToUpdate,
|
|
205
|
+
const chunks = chunkArray(membersToUpdate, GENERATION_CHUNK_SIZE);
|
|
205
206
|
|
|
206
207
|
for (let i = 0; i < chunks.length; i++) {
|
|
207
208
|
const chunk = chunks[i];
|
|
@@ -255,11 +256,25 @@ async function generateUrlsChunk(data) {
|
|
|
255
256
|
};
|
|
256
257
|
|
|
257
258
|
try {
|
|
258
|
-
// Fetch
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
|
|
259
|
+
// Fetch members in smaller batches to avoid cursor size limits
|
|
260
|
+
// hasSome with too many IDs creates cursors that exceed Wix's 150KB limit
|
|
261
|
+
const FETCH_BATCH_SIZE = 200;
|
|
262
|
+
console.log(
|
|
263
|
+
`Fetching ${memberIds.length} members from database in batches of ${FETCH_BATCH_SIZE}...`
|
|
262
264
|
);
|
|
265
|
+
|
|
266
|
+
const members = [];
|
|
267
|
+
const idBatches = chunkArray(memberIds, FETCH_BATCH_SIZE);
|
|
268
|
+
|
|
269
|
+
for (let i = 0; i < idBatches.length; i++) {
|
|
270
|
+
const idBatch = idBatches[i];
|
|
271
|
+
const batchMembers = await queryAllItems(
|
|
272
|
+
wixData.query(COLLECTIONS.MEMBERS_DATA).hasSome('_id', idBatch)
|
|
273
|
+
);
|
|
274
|
+
members.push(...batchMembers);
|
|
275
|
+
console.log(`Fetched batch ${i + 1}/${idBatches.length}: ${batchMembers.length} members`);
|
|
276
|
+
}
|
|
277
|
+
|
|
263
278
|
console.log(`Found ${members.length} members in database`);
|
|
264
279
|
|
|
265
280
|
// Create a map of _id -> member for quick lookup
|
|
@@ -289,22 +304,11 @@ async function generateUrlsChunk(data) {
|
|
|
289
304
|
|
|
290
305
|
const name = member.fullName || `${member.firstName || ''} ${member.lastName || ''}`.trim();
|
|
291
306
|
|
|
292
|
-
if (!name) {
|
|
293
|
-
console.error(`Member ${memberId} has no name data - skipping`);
|
|
294
|
-
result.failed++;
|
|
295
|
-
result.failedIds.push(memberId);
|
|
296
|
-
result.errors.push({
|
|
297
|
-
memberId,
|
|
298
|
-
error: 'No name data available',
|
|
299
|
-
});
|
|
300
|
-
continue;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
307
|
try {
|
|
304
308
|
const uniqueUrl = await ensureUniqueUrl({
|
|
305
309
|
url: '',
|
|
306
310
|
memberId: member._id,
|
|
307
|
-
fullName: name,
|
|
311
|
+
fullName: name || '', // Let ensureUniqueUrl handle fallback for empty names
|
|
308
312
|
});
|
|
309
313
|
|
|
310
314
|
console.log(`✅ Generated URL for member ${memberId}: ${uniqueUrl}`);
|
package/backend/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ const { site } = require('@wix/urls');
|
|
|
4
4
|
const { encode } = require('ngeohash');
|
|
5
5
|
|
|
6
6
|
const { COLLECTIONS, ADDRESS_STATUS_TYPES } = require('../public/consts');
|
|
7
|
-
const { formatAddress, generateId } = require('../public/Utils/sharedUtils');
|
|
7
|
+
const { formatAddress, generateId, findMainAddress } = require('../public/Utils/sharedUtils');
|
|
8
8
|
|
|
9
9
|
const { CONFIG_KEYS, GEO_HASH_PRECISION, MEMBERSHIPS_TYPES } = require('./consts');
|
|
10
10
|
const { wixData } = require('./elevated-modules');
|
|
@@ -91,16 +91,17 @@ function getAddressDisplayOptions(member) {
|
|
|
91
91
|
}
|
|
92
92
|
return displayOptions;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function getMoreAddressesToDisplay(addresses = [], addressDisplayOption = []) {
|
|
95
95
|
const visible = addresses.filter(addr => addr.addressStatus !== ADDRESS_STATUS_TYPES.DONT_SHOW);
|
|
96
96
|
if (visible.length < 2) {
|
|
97
97
|
return [];
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
const mainAddress = findMainAddress(addressDisplayOption, addresses);
|
|
100
|
+
const remainingAddressesToFormat = mainAddress
|
|
101
|
+
? visible.filter(addr => addr?.key !== mainAddress.key)
|
|
102
|
+
: visible;
|
|
103
|
+
|
|
104
|
+
return remainingAddressesToFormat
|
|
104
105
|
.map(addr => {
|
|
105
106
|
const addressString = formatAddress(addr);
|
|
106
107
|
return addressString ? { _id: generateId(), address: addressString } : null;
|
|
@@ -111,10 +112,8 @@ const getAllItems = async querySearchResult => {
|
|
|
111
112
|
let oldResults = querySearchResult;
|
|
112
113
|
console.log(`found items: ${oldResults.items.length}`);
|
|
113
114
|
const allItems = oldResults.items;
|
|
114
|
-
console.log(`total pages: ${oldResults.totalPages}`);
|
|
115
115
|
while (oldResults.hasNext()) {
|
|
116
116
|
oldResults = await oldResults.next();
|
|
117
|
-
console.log(`next page: ${oldResults.currentPage}`);
|
|
118
117
|
allItems.push(...oldResults.items);
|
|
119
118
|
}
|
|
120
119
|
console.log(`all items count : ${allItems.length}`);
|
|
@@ -216,7 +215,7 @@ module.exports = {
|
|
|
216
215
|
getSiteBaseUrl,
|
|
217
216
|
encodeXml,
|
|
218
217
|
formatDateOnly,
|
|
219
|
-
|
|
218
|
+
getMoreAddressesToDisplay,
|
|
220
219
|
isPAC_STAFF,
|
|
221
220
|
searchAllItems,
|
|
222
221
|
};
|
package/package.json
CHANGED
package/pages/Profile.js
CHANGED
|
@@ -59,9 +59,9 @@ async function profileOnReady({ $w: _$w }) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function setupAdditionalAddresses() {
|
|
62
|
-
_$w('#moreAdressesRepeater').data = profileData.
|
|
62
|
+
_$w('#moreAdressesRepeater').data = profileData.moreAddressesToDisplay;
|
|
63
63
|
|
|
64
|
-
if (profileData.
|
|
64
|
+
if (profileData.moreAddressesToDisplay.length > 0) {
|
|
65
65
|
_$w('#moreLocationButton').expand();
|
|
66
66
|
_$w('#addressTitle').collapse();
|
|
67
67
|
}
|