abmp-npm 10.0.62 → 10.0.64
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/jobs.js +12 -0
- package/backend/tasks/consts.js +1 -0
- package/backend/tasks/daily-pull-check-methods.js +88 -0
- package/backend/tasks/index.js +1 -0
- package/backend/tasks/tasks-configs.js +8 -0
- package/package.json +1 -1
- package/pages/Home.js +3 -2
- package/pages/personalDetails.js +10 -3
- package/public/Utils/sharedUtils.js +10 -0
package/backend/jobs.js
CHANGED
|
@@ -2,6 +2,7 @@ const { taskManager } = require('psdev-task-manager');
|
|
|
2
2
|
|
|
3
3
|
const { MEMBER_ACTIONS } = require('./daily-pull/consts');
|
|
4
4
|
const { TASKS_NAMES } = require('./tasks/consts');
|
|
5
|
+
const { dailyPullExecutionCheck } = require('./tasks/daily-pull-check-methods');
|
|
5
6
|
const { TASKS } = require('./tasks/tasks-configs');
|
|
6
7
|
|
|
7
8
|
async function runScheduledTasks() {
|
|
@@ -96,6 +97,16 @@ async function scheduleFixUrlsWithSpacesTask() {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
async function runDailyPullExecutionCheck() {
|
|
101
|
+
try {
|
|
102
|
+
console.log('runDailyPullExecutionCheck started!');
|
|
103
|
+
return await dailyPullExecutionCheck({});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error(`Failed to runDailyPullExecutionCheck: ${error.message}`);
|
|
106
|
+
throw new Error(`Failed to runDailyPullExecutionCheck: ${error.message}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
99
110
|
async function updateSiteMapS3() {
|
|
100
111
|
try {
|
|
101
112
|
return await taskManager().schedule({
|
|
@@ -115,4 +126,5 @@ module.exports = {
|
|
|
115
126
|
scheduleCreateContactsFromMembersTask,
|
|
116
127
|
scheduleFixPrimaryAddressForMembersTask,
|
|
117
128
|
scheduleFixUrlsWithSpacesTask,
|
|
129
|
+
runDailyPullExecutionCheck,
|
|
118
130
|
};
|
package/backend/tasks/consts.js
CHANGED
|
@@ -22,6 +22,7 @@ const TASKS_NAMES = {
|
|
|
22
22
|
fixPrimaryAddressChunk: 'fixPrimaryAddressChunk',
|
|
23
23
|
scheduleFixUrlsWithSpaces: 'scheduleFixUrlsWithSpaces',
|
|
24
24
|
fixUrlsWithSpacesChunk: 'fixUrlsWithSpacesChunk',
|
|
25
|
+
dailyPullExecutionCheck: 'dailyPullExecutionCheck',
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
module.exports = {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const { taskManager } = require('psdev-task-manager');
|
|
2
|
+
const { COLLECTIONS } = require('psdev-task-manager/public/consts');
|
|
3
|
+
|
|
4
|
+
const { MEMBER_ACTIONS } = require('../daily-pull/consts');
|
|
5
|
+
const { wixData } = require('../elevated-modules');
|
|
6
|
+
const { queryAllItems } = require('../utils');
|
|
7
|
+
|
|
8
|
+
const { TASKS_NAMES } = require('./consts');
|
|
9
|
+
|
|
10
|
+
const DEFAULT_HOURS_BACK = 4;
|
|
11
|
+
|
|
12
|
+
const getActionsToCheck = includeNone =>
|
|
13
|
+
includeNone
|
|
14
|
+
? Object.values(MEMBER_ACTIONS)
|
|
15
|
+
: Object.values(MEMBER_ACTIONS).filter(action => action !== MEMBER_ACTIONS.NONE);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Verifies ScheduleMembersDataPerAction tasks exist and succeeded per action.
|
|
19
|
+
*/
|
|
20
|
+
async function dailyPullExecutionCheck(taskData) {
|
|
21
|
+
const hoursBack =
|
|
22
|
+
taskData?.hoursBack && Number.isFinite(taskData.hoursBack)
|
|
23
|
+
? taskData.hoursBack
|
|
24
|
+
: DEFAULT_HOURS_BACK;
|
|
25
|
+
const includeNone = Boolean(taskData?.includeNone);
|
|
26
|
+
const sinceDate = new Date(Date.now() - hoursBack * 60 * 60 * 1000);
|
|
27
|
+
|
|
28
|
+
console.log('dailyPullExecutionCheck started', { hoursBack, sinceDate });
|
|
29
|
+
|
|
30
|
+
const tasksQuery = wixData
|
|
31
|
+
.query(COLLECTIONS.TASKS)
|
|
32
|
+
.eq('name', TASKS_NAMES.ScheduleMembersDataPerAction)
|
|
33
|
+
.ge('_createdDate', sinceDate)
|
|
34
|
+
.limit(1000);
|
|
35
|
+
|
|
36
|
+
const tasks = await queryAllItems(tasksQuery);
|
|
37
|
+
const actionsToCheck = getActionsToCheck(includeNone);
|
|
38
|
+
|
|
39
|
+
const statusByAction = actionsToCheck.reduce((acc, action) => {
|
|
40
|
+
acc[action] = { success: 0, failed: 0, pending: 0, in_progress: 0, skipped: 0 };
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
|
|
44
|
+
tasks.forEach(task => {
|
|
45
|
+
const action = task?.data?.action;
|
|
46
|
+
if (!action || !(action in statusByAction)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const status = task?.status || 'unknown';
|
|
50
|
+
if (!statusByAction[action][status]) {
|
|
51
|
+
statusByAction[action][status] = 0;
|
|
52
|
+
}
|
|
53
|
+
statusByAction[action][status] += 1;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const missingActions = actionsToCheck.filter(
|
|
57
|
+
action => (statusByAction[action]?.success || 0) === 0
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const result = {
|
|
61
|
+
success: missingActions.length === 0,
|
|
62
|
+
sinceDate: sinceDate.toISOString(),
|
|
63
|
+
actionsChecked: actionsToCheck,
|
|
64
|
+
missingActions,
|
|
65
|
+
statusByAction,
|
|
66
|
+
totalTasksFound: tasks.length,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (missingActions.length > 0) {
|
|
70
|
+
console.log('Missing daily pull actions detected, scheduling fallback daily pull run', {
|
|
71
|
+
missingActions,
|
|
72
|
+
});
|
|
73
|
+
await taskManager().schedule({
|
|
74
|
+
name: TASKS_NAMES.ScheduleDailyMembersDataSync,
|
|
75
|
+
data: {},
|
|
76
|
+
type: 'scheduled',
|
|
77
|
+
});
|
|
78
|
+
result.fallbackScheduled = true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.log('dailyPullExecutionCheck result', JSON.stringify(result, null, 2));
|
|
82
|
+
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = {
|
|
87
|
+
dailyPullExecutionCheck,
|
|
88
|
+
};
|
package/backend/tasks/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const {
|
|
|
9
9
|
fixPrimaryAddressChunk,
|
|
10
10
|
} = require('./address-primary-methods');
|
|
11
11
|
const { TASKS_NAMES } = require('./consts');
|
|
12
|
+
const { dailyPullExecutionCheck } = require('./daily-pull-check-methods');
|
|
12
13
|
const {
|
|
13
14
|
scheduleTaskForEmptyAboutYouMembers,
|
|
14
15
|
convertAboutYouHtmlToRichContent,
|
|
@@ -202,6 +203,13 @@ const TASKS = {
|
|
|
202
203
|
shouldSkipCheck: () => false,
|
|
203
204
|
estimatedDurationSec: 80,
|
|
204
205
|
},
|
|
206
|
+
[TASKS_NAMES.dailyPullExecutionCheck]: {
|
|
207
|
+
name: TASKS_NAMES.dailyPullExecutionCheck,
|
|
208
|
+
getIdentifier: task => task.data,
|
|
209
|
+
process: dailyPullExecutionCheck,
|
|
210
|
+
shouldSkipCheck: () => false,
|
|
211
|
+
estimatedDurationSec: 30,
|
|
212
|
+
},
|
|
205
213
|
};
|
|
206
214
|
|
|
207
215
|
module.exports = { TASKS };
|
package/package.json
CHANGED
package/pages/Home.js
CHANGED
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
formatPracticeAreasForDisplay,
|
|
11
11
|
checkAddressIsVisible,
|
|
12
12
|
isWixHostedImage,
|
|
13
|
+
normalizeExternalUrl,
|
|
13
14
|
} = require('../public/Utils/sharedUtils.js');
|
|
14
15
|
|
|
15
16
|
let filter = JSON.parse(JSON.stringify(DEFAULT_FILTER));
|
|
@@ -198,7 +199,7 @@ const homePageOnReady = async ({
|
|
|
198
199
|
$item('#websiteContainer').collapse();
|
|
199
200
|
} else {
|
|
200
201
|
if (itemData.showWebsite) {
|
|
201
|
-
$item('#website').link = itemData.website;
|
|
202
|
+
$item('#website').link = normalizeExternalUrl(itemData.website);
|
|
202
203
|
} else {
|
|
203
204
|
$item('#website').link = `${baseUrl}/profile/${itemData.url}`;
|
|
204
205
|
}
|
|
@@ -256,7 +257,7 @@ const homePageOnReady = async ({
|
|
|
256
257
|
// 9) "Book now" button
|
|
257
258
|
if (itemData.bookingUrl) {
|
|
258
259
|
$item('#bookNowButton').show();
|
|
259
|
-
$item('#bookNowButton').link = itemData.bookingUrl;
|
|
260
|
+
$item('#bookNowButton').link = normalizeExternalUrl(itemData.bookingUrl);
|
|
260
261
|
$item('#bookNowButton').target = '_blank';
|
|
261
262
|
} else {
|
|
262
263
|
$item('#bookNowButton').hide();
|
package/pages/personalDetails.js
CHANGED
|
@@ -9,7 +9,11 @@ const {
|
|
|
9
9
|
LIGHTBOX_NAMES,
|
|
10
10
|
} = require('../public/consts');
|
|
11
11
|
const { handleOnCustomValidation, isNotValidUrl } = require('../public/Utils/personalDetailsUtils');
|
|
12
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
generateId,
|
|
14
|
+
isWixHostedImage,
|
|
15
|
+
normalizeExternalUrl,
|
|
16
|
+
} = require('../public/Utils/sharedUtils');
|
|
13
17
|
|
|
14
18
|
const MAX_PHONES_COUNT = 10;
|
|
15
19
|
const MAX_ADDRESSES_COUNT = 10;
|
|
@@ -2280,12 +2284,15 @@ async function personalDetailsOnReady({
|
|
|
2280
2284
|
const addresses = Array.isArray(itemMemberObj.addresses) ? itemMemberObj.addresses : [];
|
|
2281
2285
|
const phones = Array.isArray(itemMemberObj.phones) ? itemMemberObj.phones : [];
|
|
2282
2286
|
|
|
2287
|
+
const rawWebsite = (_$w('#UrlInput').value || '').trim();
|
|
2288
|
+
const rawBooking = (_$w('#schedulingLinkInput').value || '').trim();
|
|
2289
|
+
|
|
2283
2290
|
return {
|
|
2284
2291
|
showContactForm: _$w('#showCotactFormCheckbox').checked,
|
|
2285
2292
|
contactFormEmail: _$w('#contactFormEmailInput').value,
|
|
2286
2293
|
toShowPhone: getToShowPhone(),
|
|
2287
|
-
bookingUrl:
|
|
2288
|
-
website:
|
|
2294
|
+
bookingUrl: rawBooking ? normalizeExternalUrl(rawBooking) : '',
|
|
2295
|
+
website: rawWebsite ? normalizeExternalUrl(rawWebsite) : '',
|
|
2289
2296
|
showWebsite: showExistingUrl,
|
|
2290
2297
|
showWixUrl,
|
|
2291
2298
|
addresses,
|
|
@@ -186,6 +186,15 @@ function isWixHostedImage(imageUrl) {
|
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
/** Web URLs only: bare hostnames get https:// so they are not treated as site-relative paths. */
|
|
190
|
+
function normalizeExternalUrl(url) {
|
|
191
|
+
if (!url || typeof url !== 'string') return url;
|
|
192
|
+
const trimmed = url.trim();
|
|
193
|
+
if (!trimmed) return trimmed;
|
|
194
|
+
if (/^https?:\/\//i.test(trimmed)) return trimmed;
|
|
195
|
+
return `https://${trimmed}`;
|
|
196
|
+
}
|
|
197
|
+
|
|
189
198
|
module.exports = {
|
|
190
199
|
checkAddressIsVisible,
|
|
191
200
|
formatPracticeAreasForDisplay,
|
|
@@ -198,4 +207,5 @@ module.exports = {
|
|
|
198
207
|
generateId,
|
|
199
208
|
formatAddress,
|
|
200
209
|
isWixHostedImage,
|
|
210
|
+
normalizeExternalUrl,
|
|
201
211
|
};
|