echoapi-cron-scheduler-batch 1.0.6 → 1.0.8

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.
Files changed (2) hide show
  1. package/index.js +7 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -17,7 +17,7 @@ class CronScheduler {
17
17
  constructor(config = {}) {
18
18
  // 配置初始化
19
19
  this.apiUrl = config.apiUrl || process?.env["OPENAPI_DOMAIN"] || "https://ee.apipost.cc";
20
- this.dbFile = config.dbPath || path.resolve(os.tmpdir(), 'echoapi-batch-tasks.sqlite');
20
+ this.dbFile = config.dbPath || path.resolve(process?.env?.TEMP_DIR || os.tmpdir(), 'echoapi-batch-tasks.sqlite');
21
21
  this.workerNum = config.workerNum || os.cpus().length;
22
22
 
23
23
  // 结果聚合收集器:用于收集同一批次下所有 Runner 的结果
@@ -448,19 +448,22 @@ class CronScheduler {
448
448
  job_id: record.job_info.job_id,
449
449
  report_name: record.job_info.name,
450
450
  project_id: record.job_info.project_id,
451
- user_uid: record.job_info.user_uid,
452
451
  execution_id: executionId,
453
452
  start_at: this.formatTimeToISO(record.job_info.start_time),
454
453
  end_at: this.formatTimeToISO(Date.now()),
455
454
  http_pass_rate: `${httpRate}%`,
456
455
  assert_pass_rate: `${assertRate}%`,
457
456
  avg_response_time: `${avgResp}ms`,
457
+ total_http: stats.http_total,
458
+ success_http: stats.http_success,
459
+ total_assert: stats.assert_total,
460
+ success_assert: stats.assert_success,
458
461
  total_units: record.total,
459
462
  actual_units: results.length
460
463
  },
461
464
  results: results
462
465
  };
463
- // fs.writeFileSync('finalPayload.json', JSON.stringify(finalPayload))
466
+ fs.writeFileSync('finalPayload.json', JSON.stringify(finalPayload))
464
467
  // 5. 上报 API
465
468
  const response = await axios.post(`${this.apiUrl}/open/hnzycfc/scheduled_task/report/add`, finalPayload, {
466
469
  headers: { 'Content-Type': 'application/json', 'api-token': record.api_token },
@@ -544,7 +547,7 @@ class CronScheduler {
544
547
  process.on('message', async (msg) => {
545
548
  if (msg.action === 'EXECUTE_UNIT') {
546
549
  const { executionId, api_token, test_events, option } = msg.payload;
547
- const socketPath = path.join(os.tmpdir(), `echoapi_${uuidv4()}.sock`);
550
+ const socketPath = path.join(process?.env?.TEMP_DIR || os.tmpdir(), `echoapi_${uuidv4()}.sock`);
548
551
 
549
552
  const server = net.createServer((socket) => {
550
553
  socket.on('data', async (stream) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-cron-scheduler-batch",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {