-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a55b782
commit 841256b
Showing
10 changed files
with
86 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...-metrics-by-project-v1.controller.spec.ts → ...so-metrics/oso-metrics.controller.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Controller, Get, Param } from '@nestjs/common'; | ||
import { OsoMetricsService } from './oso-metrics.service'; | ||
|
||
@Controller('v1/oso-metrics') | ||
export class OsoMetricsController { | ||
constructor(private readonly osoMetricsService: OsoMetricsService) {} | ||
|
||
@Get() | ||
findAll() { | ||
return this.osoMetricsService.findAll(); | ||
} | ||
|
||
@Get(':name') | ||
findOne(@Param('name') name: string) { | ||
return this.osoMetricsService.findOne(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { OsoMetricsService } from './oso-metrics.service'; | ||
import { OsoMetricsController } from './oso-metrics.controller'; | ||
|
||
@Module({ | ||
controllers: [OsoMetricsController], | ||
providers: [OsoMetricsService], | ||
exports: [OsoMetricsService], | ||
}) | ||
export class OsoMetricsModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { OsoMetricsService } from './oso-metrics.service'; | ||
|
||
describe('OsoMetricsService', () => { | ||
let service: OsoMetricsService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [OsoMetricsService], | ||
}).compile(); | ||
|
||
service = module.get<OsoMetricsService>(OsoMetricsService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
BadRequestException, | ||
ConflictException, | ||
Injectable, | ||
InternalServerErrorException, | ||
NotFoundException, | ||
} from '@nestjs/common'; | ||
import { OsoPrismaService } from '../shared/oso-prisma.service'; | ||
import { LogService } from '../shared/log.service'; | ||
import { Prisma } from '@prisma/client'; | ||
|
||
@Injectable() | ||
export class OsoMetricsService { | ||
constructor(private prisma: OsoPrismaService, private logger: LogService) {} | ||
|
||
findAll() { | ||
try { | ||
return this.prisma.oso_codeMetricsByProjectV1.findMany(); | ||
} catch (error) { | ||
throw new InternalServerErrorException(`Error occured while retrieving project metrics data: ${error.message}`); | ||
} | ||
} | ||
|
||
async findOne(displayName: string) { | ||
try { | ||
const metric = await this.prisma.oso_codeMetricsByProjectV1.findFirst({ | ||
where: { displayName }, | ||
}); | ||
if (!metric) { | ||
throw new NotFoundException(`Metric with display name "${displayName}" not found.`); | ||
} | ||
return metric; | ||
} catch (error) { | ||
throw new InternalServerErrorException(`Error occured while retrieving project metrics data: ${error.message}`); | ||
} | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
apps/web-api/src/oso_code-metrics-by-project-v1/oso_code-metrics-by-project-v1.controller.ts
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
apps/web-api/src/oso_code-metrics-by-project-v1/oso_code-metrics-by-project-v1.module.ts
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...web-api/src/oso_code-metrics-by-project-v1/oso_code-metrics-by-project-v1.service.spec.ts
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
apps/web-api/src/oso_code-metrics-by-project-v1/oso_code-metrics-by-project-v1.service.ts
This file was deleted.
Oops, something went wrong.