echoapi-cron-scheduler-batch 1.0.2 → 1.0.3
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/index.js +3 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -42,7 +42,6 @@ class CronScheduler {
|
|
|
42
42
|
is_cancel INTEGER DEFAULT 0,
|
|
43
43
|
api_token TEXT,
|
|
44
44
|
project_id TEXT,
|
|
45
|
-
user_uid TEXT, -- 新增:存储用户UID
|
|
46
45
|
cases TEXT, -- 存储 runners 数组 JSON
|
|
47
46
|
create_dtime INTEGER
|
|
48
47
|
)
|
|
@@ -168,7 +167,6 @@ class CronScheduler {
|
|
|
168
167
|
job_id: record.job_info.job_id,
|
|
169
168
|
report_name: record.job_info.name,
|
|
170
169
|
project_id: record.job_info.project_id,
|
|
171
|
-
user_uid: record.job_info.user_uid, // 放入最终报文
|
|
172
170
|
execution_id: executionId,
|
|
173
171
|
start_at: this.formatTimeToISO(record.job_info.start_time),
|
|
174
172
|
end_at: this.formatTimeToISO(endTime),
|
|
@@ -295,22 +293,21 @@ class CronScheduler {
|
|
|
295
293
|
* 创建或更新任务
|
|
296
294
|
*/
|
|
297
295
|
createJob(payload) {
|
|
298
|
-
const { job_id, name, frequency, api_token, project_id,
|
|
296
|
+
const { job_id, name, frequency, api_token, project_id, runners } = payload;
|
|
299
297
|
const casesJson = JSON.stringify(Array.isArray(runners) ? runners : []);
|
|
300
298
|
const freqJson = JSON.stringify(frequency);
|
|
301
299
|
|
|
302
300
|
const stmt = this.db.prepare(`
|
|
303
|
-
INSERT INTO jobs (job_id, name, frequency, api_token, project_id, cases,
|
|
301
|
+
INSERT INTO jobs (job_id, name, frequency, api_token, project_id, cases, create_dtime)
|
|
304
302
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
305
303
|
ON CONFLICT(job_id) DO UPDATE SET
|
|
306
304
|
name=excluded.name,
|
|
307
305
|
frequency=excluded.frequency,
|
|
308
306
|
cases=excluded.cases,
|
|
309
307
|
api_token=excluded.api_token,
|
|
310
|
-
user_uid=excluded.user_uid, -- 更新时也同步 UID
|
|
311
308
|
is_cancel=0
|
|
312
309
|
`);
|
|
313
|
-
stmt.run(job_id, name, freqJson, api_token, project_id,
|
|
310
|
+
stmt.run(job_id, name, freqJson, api_token, project_id, casesJson, Date.now());
|
|
314
311
|
|
|
315
312
|
// 使用增量更新,不再 loadJobs()
|
|
316
313
|
this.upsertTimer(job_id, name, frequency, { is_cancel: 0 });
|
|
@@ -395,7 +392,6 @@ class CronScheduler {
|
|
|
395
392
|
job_id: job.job_id,
|
|
396
393
|
name: job.name,
|
|
397
394
|
project_id: job.project_id,
|
|
398
|
-
user_uid: job.user_uid, // 将 UID 存入内存
|
|
399
395
|
start_time: Date.now()
|
|
400
396
|
// 如果数据库有创建人字段,也可以存入:creator: job.creator
|
|
401
397
|
}
|