@stryker-mutator/dashboard-data-access 0.17.1-pr-1163.22 → 0.17.1-pr-1190.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.
@@ -1,7 +1,10 @@
1
1
  import { MutationTestingReport, Project } from '../models/index.js';
2
+ import { MutationTestingMetrics } from '../models/MutationTestingMetrics.js';
2
3
  import type { Mapper } from './Mapper.js';
3
4
  export type MutationTestingReportMapper = Mapper<MutationTestingReport, 'projectName' | 'version', 'moduleName'>;
5
+ export type MutationTestingMetricsMapper = Mapper<MutationTestingMetrics, 'project', 'version'>;
4
6
  export type ProjectMapper = Mapper<Project, 'owner', 'name'>;
5
7
  export declare function createMutationTestingReportMapper(): MutationTestingReportMapper;
8
+ export declare function createMutationTestingMetricsMapper(): MutationTestingMetricsMapper;
6
9
  export declare function createProjectMapper(): ProjectMapper;
7
10
  //# sourceMappingURL=factories.d.ts.map
@@ -1,8 +1,12 @@
1
1
  import { MutationTestingReport, Project } from '../models/index.js';
2
+ import { MutationTestingMetrics } from '../models/MutationTestingMetrics.js';
2
3
  import TableStorageMapper from './TableStorageMapper.js';
3
4
  export function createMutationTestingReportMapper() {
4
5
  return new TableStorageMapper(MutationTestingReport);
5
6
  }
7
+ export function createMutationTestingMetricsMapper() {
8
+ return new TableStorageMapper(MutationTestingMetrics);
9
+ }
6
10
  export function createProjectMapper() {
7
11
  return new TableStorageMapper(Project);
8
12
  }
@@ -0,0 +1,28 @@
1
+ import { type Metrics } from "mutation-testing-metrics";
2
+ export declare class MutationTestingMetrics implements Metrics {
3
+ project: string;
4
+ version: string | undefined;
5
+ pending: number;
6
+ killed: number;
7
+ timeout: number;
8
+ survived: number;
9
+ noCoverage: number;
10
+ runtimeErrors: number;
11
+ compileErrors: number;
12
+ ignored: number;
13
+ totalDetected: number;
14
+ totalUndetected: number;
15
+ totalInvalid: number;
16
+ totalValid: number;
17
+ totalMutants: number;
18
+ totalCovered: number;
19
+ mutationScore: number;
20
+ mutationScoreBasedOnCoveredCode: number;
21
+ constructor(metrics?: Metrics | undefined);
22
+ static readonly persistedFields: readonly ["pending", "killed", "timeout", "survived", "noCoverage", "runtimeErrors", "compileErrors", "ignored", "totalDetected", "totalUndetected", "totalInvalid", "totalValid", "totalMutants", "totalCovered", "mutationScore", "mutationScoreBasedOnCoveredCode"];
23
+ static readonly tableName: string;
24
+ static createRowKey(identifier: Pick<MutationTestingMetrics, 'version'>): string | undefined;
25
+ static createPartitionKey(identifier: Pick<MutationTestingMetrics, 'project'>): string;
26
+ static identify(entity: Partial<MutationTestingMetrics>, partitionKey: string, rowKey: string): void;
27
+ }
28
+ //# sourceMappingURL=MutationTestingMetrics.d.ts.map
@@ -0,0 +1,72 @@
1
+ export class MutationTestingMetrics {
2
+ project; // github.com/stryker-mutator/stryker-dashboard
3
+ version; // feat/implement-metrics
4
+ pending;
5
+ killed;
6
+ timeout;
7
+ survived;
8
+ noCoverage;
9
+ runtimeErrors;
10
+ compileErrors;
11
+ ignored;
12
+ totalDetected;
13
+ totalUndetected;
14
+ totalInvalid;
15
+ totalValid;
16
+ totalMutants;
17
+ totalCovered;
18
+ mutationScore;
19
+ mutationScoreBasedOnCoveredCode;
20
+ constructor(metrics = undefined) {
21
+ if (metrics === undefined) {
22
+ return;
23
+ }
24
+ this.pending = metrics.pending;
25
+ this.killed = metrics.killed;
26
+ this.timeout = metrics.timeout;
27
+ this.survived = metrics.survived;
28
+ this.noCoverage = metrics.noCoverage;
29
+ this.runtimeErrors = metrics.runtimeErrors;
30
+ this.compileErrors = metrics.compileErrors;
31
+ this.ignored = metrics.ignored;
32
+ this.totalDetected = metrics.totalDetected;
33
+ this.totalUndetected = metrics.totalUndetected;
34
+ this.totalInvalid = metrics.totalInvalid;
35
+ this.totalValid = metrics.totalValid;
36
+ this.totalMutants = metrics.totalMutants;
37
+ this.totalCovered = metrics.totalCovered;
38
+ this.mutationScore = metrics.mutationScore;
39
+ this.mutationScoreBasedOnCoveredCode = metrics.mutationScoreBasedOnCoveredCode;
40
+ }
41
+ static persistedFields = [
42
+ 'pending',
43
+ 'killed',
44
+ 'timeout',
45
+ 'survived',
46
+ 'noCoverage',
47
+ 'runtimeErrors',
48
+ 'compileErrors',
49
+ 'ignored',
50
+ 'totalDetected',
51
+ 'totalUndetected',
52
+ 'totalInvalid',
53
+ 'totalValid',
54
+ 'totalMutants',
55
+ 'totalCovered',
56
+ 'mutationScore',
57
+ 'mutationScoreBasedOnCoveredCode',
58
+ ];
59
+ static tableName = MutationTestingMetrics.name;
60
+ static createRowKey(identifier) {
61
+ const nowUtc = new Date().toISOString();
62
+ return identifier.version + nowUtc;
63
+ }
64
+ static createPartitionKey(identifier) {
65
+ return identifier.project;
66
+ }
67
+ static identify(entity, partitionKey, rowKey) {
68
+ entity.project = partitionKey;
69
+ entity.version = rowKey;
70
+ }
71
+ }
72
+ //# sourceMappingURL=MutationTestingMetrics.js.map
@@ -1,11 +1,12 @@
1
1
  import type { Logger, MutationScoreOnlyResult, Report, ReportIdentifier } from '@stryker-mutator/dashboard-common';
2
2
  import type { MutationTestResult } from 'mutation-testing-report-schema';
3
- import type { MutationTestingReportMapper } from '../mappers/index.js';
3
+ import type { MutationTestingMetricsMapper, MutationTestingReportMapper } from '../mappers/index.js';
4
4
  import { MutationTestingResultMapper } from '../mappers/MutationTestingResultMapper.js';
5
5
  export declare class MutationTestingReportService {
6
6
  private readonly resultMapper;
7
+ private readonly mutationMetricsMapper;
7
8
  private readonly mutationScoreMapper;
8
- constructor(resultMapper?: MutationTestingResultMapper, mutationScoreMapper?: MutationTestingReportMapper);
9
+ constructor(resultMapper?: MutationTestingResultMapper, mutationMetricsMapper?: MutationTestingMetricsMapper, mutationScoreMapper?: MutationTestingReportMapper);
9
10
  createStorageIfNotExists(): Promise<void>;
10
11
  saveReport(id: ReportIdentifier, result: MutationScoreOnlyResult | MutationTestResult, logger: Logger): Promise<void>;
11
12
  private aggregateProjectReport;
@@ -1,17 +1,20 @@
1
1
  import { isMutationTestResult } from '@stryker-mutator/dashboard-common';
2
2
  import { aggregateResultsByModule, calculateMetrics } from 'mutation-testing-metrics';
3
3
  import { OptimisticConcurrencyError } from '../errors/index.js';
4
- import { createMutationTestingReportMapper, DashboardQuery } from '../mappers/index.js';
4
+ import { createMutationTestingMetricsMapper, createMutationTestingReportMapper, DashboardQuery } from '../mappers/index.js';
5
5
  import { MutationTestingResultMapper } from '../mappers/MutationTestingResultMapper.js';
6
6
  import { MutationTestingReport } from '../models/index.js';
7
+ import { MutationTestingMetrics } from '../models/MutationTestingMetrics.js';
7
8
  function moduleHasResult(tuple) {
8
9
  return !!tuple[1];
9
10
  }
10
11
  export class MutationTestingReportService {
11
12
  resultMapper;
13
+ mutationMetricsMapper;
12
14
  mutationScoreMapper;
13
- constructor(resultMapper = new MutationTestingResultMapper(), mutationScoreMapper = createMutationTestingReportMapper()) {
15
+ constructor(resultMapper = new MutationTestingResultMapper(), mutationMetricsMapper = createMutationTestingMetricsMapper(), mutationScoreMapper = createMutationTestingReportMapper()) {
14
16
  this.resultMapper = resultMapper;
17
+ this.mutationMetricsMapper = mutationMetricsMapper;
15
18
  this.mutationScoreMapper = mutationScoreMapper;
16
19
  }
17
20
  async createStorageIfNotExists() {
@@ -19,7 +22,11 @@ export class MutationTestingReportService {
19
22
  await this.mutationScoreMapper.createStorageIfNotExists();
20
23
  }
21
24
  async saveReport(id, result, logger) {
22
- const mutationScore = this.calculateMutationScore(result);
25
+ let metrics;
26
+ if (isMutationTestResult(result)) {
27
+ metrics = calculateMetrics(result.files).metrics;
28
+ }
29
+ const mutationScore = metrics?.mutationScore || 0;
23
30
  await this.insertOrMergeReport(id, {
24
31
  ...id,
25
32
  mutationScore,
@@ -27,6 +34,13 @@ export class MutationTestingReportService {
27
34
  if (isMutationTestResult(result) && id.moduleName) {
28
35
  await this.aggregateProjectReport(id.projectName, id.version, logger);
29
36
  }
37
+ if (metrics) {
38
+ const dataMetricslol = new MutationTestingMetrics(metrics);
39
+ dataMetricslol.project = id.projectName;
40
+ dataMetricslol.version = id.version;
41
+ console.log(dataMetricslol);
42
+ await this.mutationMetricsMapper.insert(dataMetricslol);
43
+ }
30
44
  }
31
45
  async aggregateProjectReport(projectName, version, logger) {
32
46
  const id = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryker-mutator/dashboard-data-access",
3
- "version": "0.17.1-pr-1163.22",
3
+ "version": "0.17.1-pr-1190.0",
4
4
  "type": "module",
5
5
  "description": "This package contains the data access layer of the stryker dashboard application.",
6
6
  "scripts": {
@@ -24,9 +24,9 @@
24
24
  "dependencies": {
25
25
  "@azure/data-tables": "13.3.0",
26
26
  "@azure/storage-blob": "12.26.0",
27
- "@stryker-mutator/dashboard-common": "0.17.1-pr-1163.22",
27
+ "@stryker-mutator/dashboard-common": "0.17.1-pr-1190.0",
28
28
  "mutation-testing-metrics": "3.3.0",
29
29
  "mutation-testing-report-schema": "3.3.0"
30
30
  },
31
- "gitHead": "61d88f2d723644692c841ce255d40c74dedd97f9"
31
+ "gitHead": "e9174af09158e0219c9cc0f7ff468ce91e29eda7"
32
32
  }