ortoni-report 2.0.7 → 2.0.9

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.
@@ -29464,6 +29464,7 @@ var DatabaseManager = class {
29464
29464
  driver: import_sqlite3.default.Database
29465
29465
  });
29466
29466
  await this.createTables();
29467
+ await this.createIndexes();
29467
29468
  } catch (error) {
29468
29469
  console.error("OrtoniReport: Error initializing database:", error);
29469
29470
  }
@@ -29494,6 +29495,20 @@ var DatabaseManager = class {
29494
29495
  console.error("OrtoniReport: Error creating tables:", error);
29495
29496
  }
29496
29497
  }
29498
+ async createIndexes() {
29499
+ if (!this.db) {
29500
+ console.error("OrtoniReport: Database not initialized");
29501
+ return;
29502
+ }
29503
+ try {
29504
+ await this.db.exec(`
29505
+ CREATE INDEX IF NOT EXISTS idx_test_id ON test_results (test_id);
29506
+ CREATE INDEX IF NOT EXISTS idx_run_id ON test_results (run_id);
29507
+ `);
29508
+ } catch (error) {
29509
+ console.error("OrtoniReport: Error creating indexes:", error);
29510
+ }
29511
+ }
29497
29512
  async saveTestRun() {
29498
29513
  if (!this.db) {
29499
29514
  console.error("OrtoniReport: Database not initialized");
@@ -29501,10 +29516,13 @@ var DatabaseManager = class {
29501
29516
  }
29502
29517
  try {
29503
29518
  const runDate = formatDateUTC(/* @__PURE__ */ new Date());
29504
- const { lastID } = await this.db.run(`
29519
+ const { lastID } = await this.db.run(
29520
+ `
29505
29521
  INSERT INTO test_runs (run_date)
29506
29522
  VALUES (?)
29507
- `, [runDate]);
29523
+ `,
29524
+ [runDate]
29525
+ );
29508
29526
  return lastID;
29509
29527
  } catch (error) {
29510
29528
  console.error("OrtoniReport: Error saving test run:", error);
@@ -29517,6 +29535,7 @@ var DatabaseManager = class {
29517
29535
  return;
29518
29536
  }
29519
29537
  try {
29538
+ await this.db.exec("BEGIN TRANSACTION;");
29520
29539
  const stmt = await this.db.prepare(`
29521
29540
  INSERT INTO test_results (run_id, test_id, status, duration, error_message)
29522
29541
  VALUES (?, ?, ?, ?, ?)
@@ -29531,7 +29550,9 @@ var DatabaseManager = class {
29531
29550
  ]);
29532
29551
  }
29533
29552
  await stmt.finalize();
29553
+ await this.db.exec("COMMIT;");
29534
29554
  } catch (error) {
29555
+ await this.db.exec("ROLLBACK;");
29535
29556
  console.error("OrtoniReport: Error saving test results:", error);
29536
29557
  }
29537
29558
  }
@@ -29541,14 +29562,17 @@ var DatabaseManager = class {
29541
29562
  return [];
29542
29563
  }
29543
29564
  try {
29544
- const results = await this.db.all(`
29565
+ const results = await this.db.all(
29566
+ `
29545
29567
  SELECT tr.status, tr.duration, tr.error_message, trun.run_date
29546
29568
  FROM test_results tr
29547
29569
  JOIN test_runs trun ON tr.run_id = trun.id
29548
29570
  WHERE tr.test_id = ?
29549
29571
  ORDER BY trun.run_date DESC
29550
29572
  LIMIT ?
29551
- `, [testId, limit]);
29573
+ `,
29574
+ [testId, limit]
29575
+ );
29552
29576
  return results.map((result) => ({
29553
29577
  ...result,
29554
29578
  run_date: formatDateLocal(result.run_date)