Skip to content

Commit

Permalink
Merge pull request #687 from palladiumkenya/feat/new-reporting-layer
Browse files Browse the repository at this point in the history
Feat/new reporting layer
  • Loading branch information
cbrianbet authored Jan 15, 2024
2 parents 521ee48 + 615d0a6 commit f61f190
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { GetOtzEnrolledAdolescentsByAgeQuery } from '../impl/get-otz-enrolled-adolescents-by-age.query';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { AggregateOtz } from './../../entities/aggregate-otz.model';
import { LineListOTZEligibilityAndEnrollments } from '../../entities/line-list-otz-eligibility-and-enrollments.model';

@QueryHandler(GetOtzEnrolledAdolescentsByAgeQuery)
export class GetOtzEnrolledAdolescentsByAgeHandler implements IQueryHandler<GetOtzEnrolledAdolescentsByAgeQuery> {
constructor(
@InjectRepository(AggregateOtz, 'mssql')
private readonly repository: Repository<AggregateOtz>
@InjectRepository(LineListOTZEligibilityAndEnrollments, 'mssql')
private readonly repository: Repository<LineListOTZEligibilityAndEnrollments>
) {
}

async execute(query: GetOtzEnrolledAdolescentsByAgeQuery): Promise<any> {
const otzTotalAdolescentsByAgeGroup = this.repository.createQueryBuilder('f')
.select(['Sum(Enrolled) totalAdolescents, AgeGroup ageGroup']);
.select(['Sum(Eligible) totalAdolescents, AgeGroup ageGroup']);

if (query.county) {
otzTotalAdolescentsByAgeGroup.andWhere('f.County IN (:...counties)', { counties: query.county });
Expand Down

0 comments on commit f61f190

Please sign in to comment.