abmp-npm 2.0.64 → 2.0.66
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,5 +1,5 @@
|
|
|
1
1
|
const PAC_API_URL = 'https://members.abmp.com/eweb/api/Wix';
|
|
2
|
-
const TEST_PAC_API_URL = 'https://members.abmp.com/
|
|
2
|
+
const TEST_PAC_API_URL = 'https://members-test.abmp.com/eweb/api/Wix';
|
|
3
3
|
const BACKUP_API_URL = 'https://psdevteamenterpris.wixstudio.com/abmp-backup/_functions';
|
|
4
4
|
const SSO_TOKEN_AUTH_API_URL = 'https://members.professionalassistcorp.com/';
|
|
5
5
|
|
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,58 @@
|
|
|
1
|
+
const { taskManager } = require('psdev-task-manager');
|
|
2
|
+
const { COLLECTIONS } = require('psdev-task-manager/public/consts');
|
|
3
|
+
|
|
4
|
+
const { wixData } = require('../elevated-modules');
|
|
5
|
+
const { queryAllItems } = require('../utils');
|
|
6
|
+
|
|
7
|
+
const { TASKS_NAMES } = require('./consts');
|
|
8
|
+
|
|
9
|
+
const DEFAULT_HOURS_BACK = 4;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Detects whether the daily pull was scheduled (cron / root task).
|
|
13
|
+
* If no `ScheduleDailyMembersDataSync` task exists in the lookback window, schedules it.
|
|
14
|
+
*/
|
|
15
|
+
async function dailyPullExecutionCheck(taskData) {
|
|
16
|
+
const hoursBack =
|
|
17
|
+
taskData?.hoursBack && Number.isFinite(taskData.hoursBack)
|
|
18
|
+
? taskData.hoursBack
|
|
19
|
+
: DEFAULT_HOURS_BACK;
|
|
20
|
+
const sinceDate = new Date(Date.now() - hoursBack * 60 * 60 * 1000);
|
|
21
|
+
|
|
22
|
+
console.log('dailyPullExecutionCheck started', { hoursBack, sinceDate });
|
|
23
|
+
|
|
24
|
+
const rootTasksQuery = wixData
|
|
25
|
+
.query(COLLECTIONS.TASKS)
|
|
26
|
+
.eq('name', TASKS_NAMES.ScheduleDailyMembersDataSync)
|
|
27
|
+
.ge('_createdDate', sinceDate);
|
|
28
|
+
|
|
29
|
+
const rootTasks = await queryAllItems(rootTasksQuery);
|
|
30
|
+
const rootTaskScheduled = rootTasks.length > 0;
|
|
31
|
+
|
|
32
|
+
const result = {
|
|
33
|
+
success: rootTaskScheduled,
|
|
34
|
+
sinceDate: sinceDate.toISOString(),
|
|
35
|
+
rootTaskName: TASKS_NAMES.ScheduleDailyMembersDataSync,
|
|
36
|
+
rootTasksFound: rootTasks.length,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (!rootTaskScheduled) {
|
|
40
|
+
console.log('ScheduleDailyMembersDataSync missing in window; scheduling root daily pull', {
|
|
41
|
+
hoursBack,
|
|
42
|
+
});
|
|
43
|
+
await taskManager().schedule({
|
|
44
|
+
name: TASKS_NAMES.ScheduleDailyMembersDataSync,
|
|
45
|
+
data: {},
|
|
46
|
+
type: 'scheduled',
|
|
47
|
+
});
|
|
48
|
+
result.fallbackScheduled = true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log('dailyPullExecutionCheck result', JSON.stringify(result, null, 2));
|
|
52
|
+
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
dailyPullExecutionCheck,
|
|
58
|
+
};
|
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 };
|