Skip to content

Commit 7681dce

Browse files
committed
refactor: lat, lon 네이밍을 줄이지 않고 사용하도록 변경 #163
1 parent 114a45c commit 7681dce

File tree

7 files changed

+37
-25
lines changed

7 files changed

+37
-25
lines changed

Diff for: backend/src/place/place.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export class PlaceService {
9696
name: name,
9797
rating: rating || null,
9898
location: {
99-
longitude: geometry.location.lng,
100-
latitude: geometry.location.lat,
99+
longitude: geometry.location.longitude,
100+
latitude: geometry.location.latitude,
101101
},
102102
formattedAddress: formatted_address || null,
103103
category: types?.[0] || null,

Diff for: backend/src/search/dto/ESPlaceSaveDTO.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export class ESPlaceSaveDTO {
88
readonly thumbnailUrl: string,
99
readonly rating: number,
1010
readonly location: {
11-
lat: number;
12-
lon: number;
11+
latitude: number;
12+
longitude: number;
1313
},
1414
readonly formattedAddress: string,
1515
readonly category: string,
@@ -28,8 +28,8 @@ export class ESPlaceSaveDTO {
2828
place.thumbnailUrl,
2929
place.rating,
3030
{
31-
lat: place.latitude,
32-
lon: place.longitude,
31+
latitude: place.latitude,
32+
longitude: place.longitude,
3333
},
3434
place.formattedAddress,
3535
place.category,

Diff for: backend/src/search/query/ElasticSearchQuery.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ export class ElasticSearchQuery {
99

1010
async searchPlace(
1111
query: string,
12-
lat?: number,
13-
long?: number,
12+
latitude?: number,
13+
longitude?: number,
1414
page: number = 1,
1515
size: number = 10,
1616
) {
1717
const tokens = await this.tokenizeQuery(query);
18-
const location = !isNaN(lat) && !isNaN(long) ? { lat, long: long } : null;
18+
const location =
19+
!isNaN(latitude) && !isNaN(longitude)
20+
? {
21+
latitude: latitude,
22+
longitude: longitude,
23+
}
24+
: null;
1925
const from = (page - 1) * size;
2026
return await this.esService.search({
2127
index: ElasticSearchConfig.PLACE_INDEX,
@@ -56,8 +62,8 @@ export class ElasticSearchQuery {
5662
...(location
5763
? [
5864
ElasticSearchQueryBuilder.GAUSS_LOCATION(
59-
location.lat,
60-
location.long,
65+
location.latitude,
66+
location.longitude,
6167
),
6268
]
6369
: []),

Diff for: backend/src/search/query/builder/LocationBuilder.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export const LocationQueryBuilders = {
22
GAUSS_LOCATION: (
3-
lat: number,
4-
long: number,
3+
latitude: number,
4+
longitude: number,
55
scale = '10km',
66
offset = '2km',
77
decay = 0.5,
88
weight = 20,
99
) => ({
1010
gauss: {
1111
location: {
12-
origin: `${lat},${long}`,
12+
origin: `${latitude},${longitude}`,
1313
scale: scale,
1414
offset: offset,
1515
decay: decay,

Diff for: backend/src/search/search.controller.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ export class SearchController {
99
@Get()
1010
async search(
1111
@Query('query') query: string,
12-
@Query('lat') lat?: number,
13-
@Query('long') long?: number,
12+
@Query('latitude') latitude?: number,
13+
@Query('longitude') longitude?: number,
1414
@Query('page', new ParseOptionalNumberPipe(1)) page?: number,
1515
@Query('limit', new ParseOptionalNumberPipe(10)) limit?: number,
1616
) {
17-
return await this.searchService.searchPlace(query, lat, long, page, limit);
17+
return await this.searchService.searchPlace(
18+
query,
19+
latitude,
20+
longitude,
21+
page,
22+
limit,
23+
);
1824
}
1925
}

Diff for: backend/src/search/search.service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ export class SearchService {
3535

3636
async searchPlace(
3737
query: string,
38-
lat?: number,
39-
long?: number,
38+
latitude?: number,
39+
longitude?: number,
4040
page: number = 1,
4141
size: number = 10,
4242
) {
4343
const searched = await this.elasticSearchQuery.searchPlace(
4444
query,
45-
lat,
46-
long,
45+
latitude,
46+
longitude,
4747
page,
4848
size,
4949
);
@@ -61,8 +61,8 @@ export class SearchService {
6161
_source.name,
6262
_source.location
6363
? {
64-
latitude: _source.location.lat,
65-
longitude: _source.location.long,
64+
latitude: _source.location.latitude,
65+
longitude: _source.location.longitude,
6666
}
6767
: null,
6868
_source.googlePlaceId,

Diff for: backend/src/search/search.type.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export type PlaceSearchHit = {
66
id: string;
77
name: string;
88
location: {
9-
lat: number;
10-
long: number;
9+
latitude: number;
10+
longitude: number;
1111
};
1212
googlePlaceId: string;
1313
category: string | null;

0 commit comments

Comments
 (0)