@stryker-mutator/dashboard-data-access 0.19.1 → 0.19.2-master.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.
@@ -10,5 +10,6 @@ export interface Mapper<TModel, TPartitionKeyFields extends keyof TModel, TRowKe
10
10
  replace(model: TModel, etag: string): Promise<Result<TModel>>;
11
11
  findOne(identifier: Pick<TModel, TPartitionKeyFields | TRowKeyFields>): Promise<Result<TModel> | null>;
12
12
  findAll(query: DashboardQuery<TModel, TPartitionKeyFields, TRowKeyFields>): Promise<Result<TModel>[]>;
13
+ delete(identifier: Pick<TModel, TPartitionKeyFields | TRowKeyFields>): Promise<void>;
13
14
  }
14
15
  //# sourceMappingURL=Mapper.d.ts.map
@@ -18,6 +18,7 @@ export default class TableStorageMapper<TModel extends object, TPartitionKeyFiel
18
18
  */
19
19
  replace(model: TModel, etag: string): Promise<Result<TModel>>;
20
20
  insert(model: TModel): Promise<Result<TModel>>;
21
+ delete(identity: Pick<TModel, TPartitionKeyFields | TRowKeyFields>): Promise<void>;
21
22
  private toModel;
22
23
  private toEntity;
23
24
  }
@@ -81,6 +81,19 @@ export default class TableStorageMapper {
81
81
  }
82
82
  }
83
83
  }
84
+ async delete(identity) {
85
+ try {
86
+ await this.#tableClient.deleteEntity(encodeKey(this.ModelClass.createPartitionKey(identity)), encodeKey(this.ModelClass.createRowKey(identity) || ''));
87
+ }
88
+ catch (err) {
89
+ if (hasErrorCode(err, errCodes.RESOURCE_NOT_FOUND)) {
90
+ // Already deleted, no need to throw
91
+ }
92
+ else {
93
+ throw err;
94
+ }
95
+ }
96
+ }
84
97
  toModel(entity) {
85
98
  const value = new this.ModelClass();
86
99
  this.ModelClass.identify(value, decodeKey(entity.partitionKey), decodeKey(entity.rowKey));
@@ -9,9 +9,10 @@ export declare class MutationTestingReportService {
9
9
  createStorageIfNotExists(): Promise<void>;
10
10
  saveReport(id: ReportIdentifier, result: MutationScoreOnlyResult | MutationTestResult, logger: Logger): Promise<void>;
11
11
  private aggregateProjectReport;
12
+ private deleteModules;
12
13
  private tryAggregateProjectReport;
13
14
  findOne(id: ReportIdentifier): Promise<Report | null>;
14
- delete(id: ReportIdentifier): Promise<void>;
15
+ delete(id: ReportIdentifier, logger: Logger): Promise<void>;
15
16
  private insertOrMergeReport;
16
17
  private calculateMutationScore;
17
18
  }
@@ -40,6 +40,24 @@ export class MutationTestingReportService {
40
40
  });
41
41
  }
42
42
  }
43
+ async deleteModules(projectName, version) {
44
+ const id = {
45
+ projectName,
46
+ version,
47
+ moduleName: undefined,
48
+ };
49
+ const modules = await this.mutationScoreMapper.findAll(DashboardQuery.create(MutationTestingReport)
50
+ .wherePartitionKeyEquals(id)
51
+ .whereRowKeyNotEquals({ moduleName: undefined }));
52
+ await Promise.all(modules.map(async (module) => {
53
+ const id = {
54
+ projectName,
55
+ version,
56
+ moduleName: module.model.moduleName,
57
+ };
58
+ return Promise.all([await this.resultMapper.delete(id), await this.mutationScoreMapper.delete(id)]);
59
+ }));
60
+ }
43
61
  async tryAggregateProjectReport(id) {
44
62
  const projectMutationScoreModel = await this.mutationScoreMapper.findOne(id);
45
63
  const moduleScoreResults = await this.mutationScoreMapper.findAll(DashboardQuery.create(MutationTestingReport)
@@ -93,8 +111,14 @@ export class MutationTestingReportService {
93
111
  return null;
94
112
  }
95
113
  }
96
- async delete(id) {
97
- await this.resultMapper.delete(id);
114
+ async delete(id, logger) {
115
+ await Promise.all([this.resultMapper.delete(id), this.mutationScoreMapper.delete(id)]);
116
+ if (id.moduleName) {
117
+ await this.aggregateProjectReport(id.projectName, id.version, logger);
118
+ }
119
+ else {
120
+ await this.deleteModules(id.projectName, id.version);
121
+ }
98
122
  }
99
123
  async insertOrMergeReport(id, report, result) {
100
124
  await Promise.all([this.resultMapper.insertOrReplace(id, result), this.mutationScoreMapper.insertOrMerge(report)]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryker-mutator/dashboard-data-access",
3
- "version": "0.19.1",
3
+ "version": "0.19.2-master.0",
4
4
  "type": "module",
5
5
  "description": "This package contains the data access layer of the stryker dashboard application.",
6
6
  "scripts": {
@@ -23,10 +23,10 @@
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
25
  "@azure/data-tables": "13.3.0",
26
- "@azure/storage-blob": "12.26.0",
27
- "@stryker-mutator/dashboard-common": "0.19.1",
26
+ "@azure/storage-blob": "12.27.0",
27
+ "@stryker-mutator/dashboard-common": "0.19.2-master.0",
28
28
  "mutation-testing-metrics": "3.5.1",
29
29
  "mutation-testing-report-schema": "3.5.1"
30
30
  },
31
- "gitHead": "4461ada2b551b1987611ef92cc949d6818e7afab"
31
+ "gitHead": "5ce6fbf30163a73485c593ad6f946b259ff4370c"
32
32
  }