@dionlarson/playwright-orchestrator-pg 1.3.9 → 1.4.0

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.
@@ -16,6 +16,7 @@ export declare class PostgreSQLAdapter extends Adapter {
16
16
  startShard(runId: string): Promise<TestRunConfig>;
17
17
  finishShard(runId: string): Promise<void>;
18
18
  dispose(): Promise<void>;
19
+ cleanupStaleTests(runId: string, staleMinutes: number): Promise<number>;
19
20
  getReportData(runId: string): Promise<TestRunReport>;
20
21
  private updateTestWithResults;
21
22
  private loadTestInfos;
@@ -201,6 +201,17 @@ export class PostgreSQLAdapter extends Adapter {
201
201
  return;
202
202
  await this.pool.end();
203
203
  }
204
+ async cleanupStaleTests(runId, staleMinutes) {
205
+ const result = await this.pool.query({
206
+ text: `UPDATE ${this.testsTable}
207
+ SET status = $1, updated = NOW()
208
+ WHERE run_id = $2
209
+ AND status = $3
210
+ AND updated < NOW() - INTERVAL '1 minute' * $4`,
211
+ values: [TestStatus.Ready, runId, TestStatus.Ongoing, staleMinutes],
212
+ });
213
+ return result.rowCount ?? 0;
214
+ }
204
215
  async getReportData(runId) {
205
216
  const { rows: [dbConfig], } = await this.pool.query({
206
217
  text: `SELECT * FROM ${this.configTable} WHERE id = $1`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dionlarson/playwright-orchestrator-pg",
3
- "version": "1.3.9",
3
+ "version": "1.4.0",
4
4
  "keywords": [],
5
5
  "author": "Rostyslav Kudrevatykh",
6
6
  "license": "Apache-2.0",