Skip to content

Commit

Permalink
Merge pull request #94 from fraunhofer-iem/feature/endpoints
Browse files Browse the repository at this point in the history
added missing endpoints
  • Loading branch information
janniclas authored Mar 4, 2022
2 parents afe0143 + 4ab533f commit 6635c88
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
36 changes: 32 additions & 4 deletions src/kpi/kpi.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,42 @@ export class KpiController {
@Query('fileFilter') fileFilter?: string[],
@Query('couplingSize') couplingSize?: number,
@Query('occs') occurences?: number,
@Query('timeToComplete') timeToComplete?: number,
) {
this.logger.log(`Received query for KPI with id ${id}`);
switch (id) {
case 'fcr':
case 'icr':
this.logger.log(
`Calculating feature rate completion for ${owner}/${repo}`,
`Calculating issue completion rate for ${owner}/${repo}`,
);
return this.issueTrackingService.issueCompletionRate(
owner,
repo,
labelFilter,
);

case 'icc':
this.logger.log(
`Calculating issue completion capability for ${owner}/${repo}`,
);
return this.issueTrackingService.issueCompletionCapability(
owner,
repo,
labelFilter,
timeToComplete,
);

case 'ice':
this.logger.log(
`Calculating issue completion efficiency for ${owner}/${repo}`,
);
return this.issueTrackingService.issueCompletionEfficiency(
owner,
repo,
labelFilter,
timeToComplete,
);

case 'devSpread':
this.logger.log(`Calculating developer spread for ${owner}/${repo}`);
return this.developerSpreadService.developerSpread(
Expand All @@ -50,6 +74,7 @@ export class KpiController {
since,
to,
);

case 'releaseCycle':
this.logger.log(`Calculating the release cycle for ${owner}/${repo}`);
return this.releaseCycleService.releaseCycle(
Expand All @@ -59,6 +84,7 @@ export class KpiController {
since,
to,
);

case 'coc':
this.logger.log(
`Calculating coupling of components for ${owner}/${repo}`,
Expand All @@ -74,7 +100,9 @@ export class KpiController {
);

case 'mttr':
this.logger.log('Get Mean Time To Resolution');
this.logger.log(
`Calculating the mean time to resolution for ${owner}/${repo}`,
);
return this.meanTimeToResolutionService.meanTimeToResolution(
{
owner: owner,
Expand All @@ -87,7 +115,7 @@ export class KpiController {
);

default:
return 'no such kpi endpoint';
return 'No such KPI';
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/kpi/statistics/issueTracking/issueTracking.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { RepositoryIdentifier } from '../../../entities/repositories/model';
import { RepositoryDocument } from '../../../entities/repositories/model/schemas';
import {
calculateAvgCapability,
Expand All @@ -19,13 +18,13 @@ export class IssueTrackingService {
async issueCompletionRate(
owner: string,
repository: string,
labelNames?: string[],
labelFilter?: string[],
) {
const repo = await this.repoService.read(
{ owner: owner, repo: repository },
{ commits: false, diffs: false },
);
await this.populateRepository(repo, labelNames);
await this.populateRepository(repo, labelFilter);

const releaseIssueMap = mapReleasesToIssues(repo.releases, repo.issues);
const { avgRate, rateMap } = calculateAvgRate(releaseIssueMap);
Expand All @@ -36,12 +35,13 @@ export class IssueTrackingService {
}

async issueCompletionCapability(
repoIdent: RepositoryIdentifier,
owner: string,
repository: string,
labelNames?: string[],
timeToComplete: number = 14 * 24 * 60 * 60 * 1000,
) {
const repo = await this.repoService.read(
{ ...repoIdent },
{ owner: owner, repo: repository },
{ commits: false, diffs: false },
);
await this.populateRepository(repo, labelNames);
Expand All @@ -56,12 +56,13 @@ export class IssueTrackingService {
}

async issueCompletionEfficiency(
repoIdent: RepositoryIdentifier,
owner: string,
repository: string,
labelNames?: string[],
timeToComplete: number = 14 * 24 * 60 * 60 * 1000,
) {
const repo = await this.repoService.read(
{ ...repoIdent },
{ owner: owner, repo: repository },
{ commits: false, diffs: false },
);
await this.populateRepository(repo, labelNames);
Expand Down

0 comments on commit 6635c88

Please sign in to comment.