Skip to content

Commit

Permalink
fix: review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanth-ideas2it authored and madan-ideas2it committed Dec 20, 2024
1 parent a55b782 commit 841256b
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 76 deletions.
4 changes: 2 additions & 2 deletions apps/web-api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { MemberFeedbacksModule } from './member-feedbacks/member-feedbacks.modul
import { HuskyModule } from './husky/husky.module';
import { HomeModule } from './home/home.module';
import { InternalsModule } from './internals/internals.module';
import { OsoCodeMetricsByProjectV1Module } from './oso_code-metrics-by-project-v1/oso_code-metrics-by-project-v1.module';
import { OsoMetricsModule } from './oso-metrics/oso-metrics.module';

@Module({
controllers: [AppController],
Expand Down Expand Up @@ -98,7 +98,7 @@ import { OsoCodeMetricsByProjectV1Module } from './oso_code-metrics-by-project-v
HuskyModule,
HomeModule,
InternalsModule,
OsoCodeMetricsByProjectV1Module,
OsoMetricsModule,
],
providers: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OsoCodeMetricsByProjectV1Controller } from './oso_code-metrics-by-project-v1.controller';
import { OsoCodeMetricsByProjectV1Service } from './oso_code-metrics-by-project-v1.service';
import { OsoCodeMetricsByProjectV1Controller } from './oso-metrics.controller';
import { OsoCodeMetricsByProjectV1Service } from './oso-metrics.service';

describe('OsoCodeMetricsByProjectV1Controller', () => {
let controller: OsoCodeMetricsByProjectV1Controller;
Expand Down
17 changes: 17 additions & 0 deletions apps/web-api/src/oso-metrics/oso-metrics.controller.ts
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);
}
}
10 changes: 10 additions & 0 deletions apps/web-api/src/oso-metrics/oso-metrics.module.ts
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 {}
18 changes: 18 additions & 0 deletions apps/web-api/src/oso-metrics/oso-metrics.service.spec.ts
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();
});
});
37 changes: 37 additions & 0 deletions apps/web-api/src/oso-metrics/oso-metrics.service.ts
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}`);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 841256b

Please sign in to comment.