@dionlarson/playwright-orchestrator-mongo 1.3.8 → 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.
@@ -20,6 +20,7 @@ export declare class MongoDbAdapter extends Adapter {
20
20
  private mapDbToTestRunConfig;
21
21
  finishShard(runId: string): Promise<void>;
22
22
  dispose(): Promise<void>;
23
+ cleanupStaleTests(runId: string, staleMinutes: number): Promise<number>;
23
24
  getReportData(runId: string): Promise<TestRunReport>;
24
25
  private get runs();
25
26
  private get tests();
@@ -207,6 +207,19 @@ export class MongoDbAdapter extends Adapter {
207
207
  async dispose() {
208
208
  await this.client.close();
209
209
  }
210
+ async cleanupStaleTests(runId, staleMinutes) {
211
+ const staleThreshold = new Date(Date.now() - staleMinutes * 60 * 1000);
212
+ const result = await this.tests.updateMany({
213
+ ...this.generateTestIdQuery(runId, TestStatus.Ongoing),
214
+ updated: { $lt: staleThreshold },
215
+ }, {
216
+ $set: {
217
+ status: TestStatus.Ready,
218
+ updated: new Date(),
219
+ },
220
+ });
221
+ return result.modifiedCount;
222
+ }
210
223
  async getReportData(runId) {
211
224
  const run = await this.runs.findOne({ _id: this.generateRunId(runId) });
212
225
  if (!run) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dionlarson/playwright-orchestrator-mongo",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "keywords": [],
5
5
  "author": "Rostyslav Kudrevatykh",
6
6
  "license": "Apache-2.0",