Skip to content

Commit

Permalink
remove countries repository
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Oct 25, 2024
1 parent 2a34840 commit a00ccb7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
6 changes: 2 additions & 4 deletions api/src/modules/countries/countries.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Country } from '@shared/entities/countries/country.entity';
import { CountriesController } from '@api/modules/countries/countries.controller';

import { MapController } from './map/map.controller';
import { CountryRepository } from '@api/modules/countries/countries.repository';
import { MapRepository } from '@api/modules/countries/map/map.repository';
import { Country } from '@shared/entities/country.entity';

@Module({
imports: [TypeOrmModule.forFeature([Country])],
controllers: [CountriesController, MapController],
providers: [CountryRepository, MapRepository],
providers: [MapRepository],
exports: [],
})
export class CountriesModule {}
14 changes: 0 additions & 14 deletions api/src/modules/countries/countries.repository.ts

This file was deleted.

14 changes: 5 additions & 9 deletions api/src/modules/countries/map/map.repository.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
import { FeatureCollection, Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { Country } from '@shared/entities/countries/country.entity';
import { BaseData } from '@api/modules/model/base-data.entity';
import { Country } from '@shared/entities/country.entity';
import { BaseData } from '@shared/entities/base-data.entity';

/**
* @description: The aim for this repository is to work with geospatial data, for now "geometry" column in countries
Expand All @@ -21,14 +21,10 @@ export class MapRepository extends Repository<Country> {
}

async getGeoFeatures(
countryCode: Country['countryCode'],
countryCode: Country['code'],
): Promise<FeatureCollection> {
const queryBuilder = this.createQueryBuilder('country');
queryBuilder.innerJoin(
BaseData,
'bd',
'bd.country_code = country.country_code',
);
queryBuilder.innerJoin(BaseData, 'bd', 'bd.country_code = country.code');
queryBuilder.select(
`
json_build_object(
Expand All @@ -44,7 +40,7 @@ export class MapRepository extends Repository<Country> {
'geojson',
);
if (countryCode) {
queryBuilder.where('country.country_code = :countryCode', {
queryBuilder.where('country.code = :countryCode', {
countryCode,
});
}
Expand Down

0 comments on commit a00ccb7

Please sign in to comment.