Skip to content

[Fix] 내가 다녀온 산 목록 API에서 imageUrl null 반환 수정#159

Merged
howooyeon merged 1 commit into
developfrom
fix/#158-mountain-image-url
May 29, 2026
Merged

[Fix] 내가 다녀온 산 목록 API에서 imageUrl null 반환 수정#159
howooyeon merged 1 commit into
developfrom
fix/#158-mountain-image-url

Conversation

@howooyeon

@howooyeon howooyeon commented May 29, 2026

Copy link
Copy Markdown
Contributor

🧾 요약

  • 내가 다녀온 산 목록 API(/api/hiking-records/me/mountains)에서 imageUrl이 null로 내려오는 버그 수정 — 존재하지 않는 image_url 컬럼 대신 image_urls->>0으로 변경

🔗 이슈

✨ 변경 내용

  • HikingRecordRepository.findUserHikingMountainRecordsByUserId 쿼리에서 m.image_urlm.image_urls->>0으로 변경
  • GROUP BY 절도 동일하게 수정

✅ 확인

  • 빌드 OK
  • 테스트 OK

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

본 PR은 사용자가 다녀온 산 목록을 조회하는 API에서 산 이미지 URL이 올바르게 표시되지 않던 버그를 수정합니다. 데이터베이스 스키마 변경 사항을 반영하여 잘못된 컬럼 참조를 수정함으로써 데이터 조회 기능을 정상화하는 것을 목적으로 합니다.

Highlights

  • 이미지 URL 조회 로직 수정: 내가 다녀온 산 목록 API에서 imageUrl이 null로 반환되던 문제를 해결하기 위해, 존재하지 않는 image_url 컬럼 대신 JSONB 데이터인 image_urls->>0을 사용하도록 쿼리를 수정했습니다.
  • GROUP BY 절 업데이트: 변경된 컬럼 참조에 맞춰 GROUP BY 절의 필드도 m.image_urls->>0으로 업데이트하여 쿼리 정합성을 맞췄습니다.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a3b8d65-a6d1-44df-9fcb-2770d97ae4d9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/#158-mountain-image-url

Comment @coderabbitai help to get the list of available commands and usage tips.

@howooyeon howooyeon changed the title fix: 내가 다녀온 산 목록 API에서 imageUrl null 반환 수정 [Fix] 내가 다녀온 산 목록 API에서 imageUrl null 반환 수정 May 29, 2026
@howooyeon
howooyeon merged commit 09841d2 into develop May 29, 2026
3 checks passed
@howooyeon howooyeon self-assigned this May 29, 2026
@howooyeon howooyeon added the bug Something isn't working label May 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the HikingRecordRepository to extract the first image URL from a JSONB array (image_urls->>0) instead of using a single image_url column. The review feedback suggests optimizing the SQL query by grouping by the primary key m.id instead of repeating multiple columns in the GROUP BY clause, leveraging PostgreSQL's functional dependency to simplify the query and improve maintainability.

Comment on lines 35 to 46
SELECT
hr.mountain_id AS mountainId,
m.name AS mountainName,
m.image_url AS imageUrl,
m.image_urls->>0 AS imageUrl,
COUNT(hr.id) AS hikingCount,
MAX(hr.created_at) AS lastHikedAt
FROM hiking_records hr
JOIN hiking_members hm ON hm.hiking_record_id = hr.id
JOIN mountains m ON m.id = hr.mountain_id
WHERE hm.user_id = :userId
GROUP BY hr.mountain_id, m.name, m.image_url
GROUP BY hr.mountain_id, m.name, m.image_urls->>0
ORDER BY MAX(hr.created_at) DESC, hr.mountain_id DESC

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

PostgreSQL에서는 GROUP BY 절에 테이블의 기본 키(Primary Key)인 m.id를 지정하면, 해당 테이블의 다른 컬럼들(m.name, m.image_urls->>0 등)은 함수적 종속성(Functional Dependency) 덕분에 GROUP BY 절에 개별적으로 나열하지 않고도 SELECT 절에서 자유롭게 조회할 수 있습니다.\n\n현재 쿼리에서는 m.image_urls->>0과 같은 복잡한 표현식이 SELECTGROUP BY 양쪽에 중복되어 작성되어 있어, 향후 이미지 조회 로직이 변경될 때 두 곳 모두 수정해야 하는 유지보수 상의 번거로움이 있습니다.\n\n따라서 SELECT 절에서 hr.mountain_id 대신 m.id를 조회하고, GROUP BY 절을 m.id로 단순화하면 쿼리의 가독성과 유지보수성을 크게 향상시킬 수 있습니다.

Suggested change
SELECT
hr.mountain_id AS mountainId,
m.name AS mountainName,
m.image_url AS imageUrl,
m.image_urls->>0 AS imageUrl,
COUNT(hr.id) AS hikingCount,
MAX(hr.created_at) AS lastHikedAt
FROM hiking_records hr
JOIN hiking_members hm ON hm.hiking_record_id = hr.id
JOIN mountains m ON m.id = hr.mountain_id
WHERE hm.user_id = :userId
GROUP BY hr.mountain_id, m.name, m.image_url
GROUP BY hr.mountain_id, m.name, m.image_urls->>0
ORDER BY MAX(hr.created_at) DESC, hr.mountain_id DESC
SELECT\n m.id AS mountainId,\n m.name AS mountainName,\n m.image_urls->>0 AS imageUrl,\n COUNT(hr.id) AS hikingCount,\n MAX(hr.created_at) AS lastHikedAt\n FROM hiking_records hr\n JOIN hiking_members hm ON hm.hiking_record_id = hr.id\n JOIN mountains m ON m.id = hr.mountain_id\n WHERE hm.user_id = :userId\n GROUP BY m.id\n ORDER BY MAX(hr.created_at) DESC, m.id DESC
References
  1. 우선순위 가이드에 따라 유지보수성(Maintainability) 및 가독성(Readability)을 개선하기 위해 중복된 표현식을 제거하고 쿼리를 단순화합니다. (link)

@howooyeon
howooyeon deleted the fix/#158-mountain-image-url branch June 3, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] /api/hiking-records/me/mountains 응답에서 imageUrl이 null인 문제

1 participant