would-you-study-with-me / siksa-clock

째깍식사 : 밥 먹는데 헛걸음을 하지 않도록 선택을 도와주는 것
1 stars 0 forks source link

[Bug] endpoint 하나로 만들기 #129

Closed hyeonprojects closed 1 year ago

hyeonprojects commented 1 year ago

버그 설명

endpoint가 두 개인 건 GraphQL의 기본 정신에 위반되어서 하나로 통일

버그 발견 경로

2023/01/10 모임 진행시에 논의된 이슈로 인해서 작업 시작

hyeonprojects commented 1 year ago

추가적 이슈 발생

작업 진행하였고, 관련해서 restaurant query에 좌표값 인자를 추가할 경우에 쿼리 에러가 나기 시작함.

hyeonprojects commented 1 year ago

원인 분석

restaurants query에 에러가 나기 시작함

예측 분석

추가 테스트 필요한 부분

관련 사진 아래를 참고 error igraphql

hyeonprojects commented 1 year ago

Error Log

[SQL: SELECT anon_1.restaurant_id, anon_1.restaurant_name, anon_1.restaurant_rate, anon_1.restaurant_category, anon_1.restaurant_count_seats, anon_1.restaurant_x, anon_1.restaurant_y, anon_1.restaurant_address, anon_1.restaurant_description, anon_1.restaurant_contact, anon_1.restaurant_created_at, anon_1.restaurant_updated_at, anon_1.restaurant_image, anon_1.restaurant_menu, anon_1.opening_time_id, anon_1.restaurant_id_1, anon_1.restaurant_opening_time_days, anon_1.restaurant_opening_time, anon_1.restaurant_break_time_days, anon_1.restaurant_break_time, anon_1.opening_time_created_at, anon_1.opening_time_updated_at, anon_1.st_distance_sphere_1, opening_time_1.opening_time_id AS opening_time_id_1, opening_time_1.restaurant_id AS restaurant_id_2, opening_time_1.restaurant_opening_time_days AS restaurant_opening_time_days_1, opening_time_1.restaurant_opening_time AS restaurant_opening_time_1, opening_time_1.restaurant_break_time_days AS restaurant_break_time_days_1, opening_time_1.restaurant_break_time AS restaurant_break_time_1, opening_time_1.opening_time_created_at AS opening_time_created_at_1, opening_time_1.opening_time_updated_at AS opening_time_updated_at_1, restaurant_1.restaurant_id AS restaurant_id_3, restaurant_1.restaurant_name AS restaurant_name_1, restaurant_1.restaurant_rate AS restaurant_rate_1, restaurant_1.restaurant_category AS restaurant_category_1, restaurant_1.restaurant_count_seats AS restaurant_count_seats_1, restaurant_1.restaurant_x AS restaurant_x_1, restaurant_1.restaurant_y AS restaurant_y_1, restaurant_1.restaurant_address AS restaurant_address_1, restaurant_1.restaurant_description AS restaurant_description_1, restaurant_1.restaurant_contact AS restaurant_contact_1, restaurant_1.restaurant_created_at AS restaurant_created_at_1, restaurant_1.restaurant_updated_at AS restaurant_updated_at_1, restaurant_1.restaurant_image AS restaurant_image_1, restaurant_1.restaurant_menu AS restaurant_menu_1 
FROM (SELECT restaurant.restaurant_id AS restaurant_id, restaurant.restaurant_name AS restaurant_name, restaurant.restaurant_rate AS restaurant_rate, restaurant.restaurant_category AS restaurant_category, restaurant.restaurant_count_seats AS restaurant_count_seats, restaurant.restaurant_x AS restaurant_x, restaurant.restaurant_y AS restaurant_y, restaurant.restaurant_address AS restaurant_address, restaurant.restaurant_description AS restaurant_description, restaurant.restaurant_contact AS restaurant_contact, restaurant.restaurant_created_at AS restaurant_created_at, restaurant.restaurant_updated_at AS restaurant_updated_at, restaurant.restaurant_image AS restaurant_image, restaurant.restaurant_menu AS restaurant_menu, opening_time.opening_time_id AS opening_time_id, opening_time.restaurant_id AS restaurant_id_1, opening_time.restaurant_opening_time_days AS restaurant_opening_time_days, opening_time.restaurant_opening_time AS restaurant_opening_time, opening_time.restaurant_break_time_days AS restaurant_break_time_days, opening_time.restaurant_break_time AS restaurant_break_time, opening_time.opening_time_created_at AS opening_time_created_at, opening_time.opening_time_updated_at AS opening_time_updated_at, st_distance_sphere(point(%s, %s), point(restaurant.restaurant_x, restaurant.restaurant_y)) AS st_distance_sphere_1 
FROM restaurant INNER JOIN opening_time ON restaurant.restaurant_id = opening_time.restaurant_id 
WHERE restaurant.restaurant_address LIKE %s ORDER BY st_distance_sphere(point(%s, %s), point(restaurant.restaurant_x, restaurant.restaurant_y)) 
 LIMIT %s, %s) AS anon_1 INNER JOIN opening_time AS opening_time_1 ON anon_1.restaurant_id = opening_time_1.restaurant_id INNER JOIN restaurant AS restaurant_1 ON restaurant_1.restaurant_id = anon_1.restaurant_id_1 ORDER BY anon_1.st_distance_sphere_1]
[parameters: (129.0832792851, 35.2424891575, '%%장전동%%', 129.0832792851, 35.2424891575, 0, 10)]
hyeonprojects commented 1 year ago

쿼리가 이상하게 들어오네요. 너무 비 효율적으로 돌아가고 있어서 ORM을 더 깊게 파서 해결하는거 보다는 SQL 쿼리를 그대로 보내는 방법이 더 좋아보이네요.

hyeonprojects commented 1 year ago

추후에는 의존성을 제거하면서 DI를 적절하게 활용하는 코드를 작성했으면 좋겠다.

hyeonprojects commented 1 year ago

쿼리 분석을 해야할거 같습니다. ㅠ ㅠ

hyeonprojects commented 1 year ago

이슈 트래킹

원인

더 보았으면 좋은점