KUIT-HealthMate / HealthMate-Backend

0 stars 3 forks source link

[Bug] challenge checker ๋ฒ„๊ทธ #52

Closed kamothi closed 2 months ago

kamothi commented 2 months ago

๐Ÿ’ก Feature Issue

ํ˜„์žฌ ์ €ํฌ์˜ ๋กœ์ง์€ ์ฑŒ๋ฆฐ์ง€ ์ƒ์„ฑํ•˜๊ณ  ์‚ฌ์šฉ์ž๊ฐ€ ํ•ด๋‹น ์ฑŒ๋ฆฐ์ง€ ์„ฑ๊ณต ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์ฒด์ปค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๊ฑฐ๊ธฐ์— ์„ฑ๊ณต ์—ฌ๋ถ€, ๋‚ ์งœ๋ฅผ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ๋  ๊ฒฝ์šฐ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๊ฐ€ ํŠน์ • ๊ธฐ๊ฐ„์— ์ฑŒ๋ฆฐ์ง€๋ฅผ ์กฐํšŒํ•  ๋•Œ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

@Query("SELECT DISTINCT h from Habit h join fetch h.habitChecker hc WHERE h.userId= :userId and hc.createdAt between :startDate and :endDate")
    List<Habit> findAllByUserIdAndCreatedAtBetween(@Param("userId") Long userId,
                                                   @Param("startDate") LocalDate startDate,
                                                   @Param("endDate") LocalDate endDate);

๋‹ค์Œ์ฒ˜๋Ÿผ ์ฟผ๋ฆฌ๋ฅผ ๋‚ ๋ฆฐ๋‹ค๊ณ  ํ–ˆ์„ ๋•Œ ๋งŒ์•ฝ ์ฒด์ปค๊ฐ€ ์—†๋‹ค๋ฉด? ๊ฐ€์ ธ์˜ค์ง€ ๋ชปํ•˜๊ฒŒ๋ฉ๋‹ˆ๋‹ค. ๋ถ„๋ช… ํ•ด๋‹น ์ฑŒ๋ฆฐ์ง€๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ๋Š”๋ฐ๋„ ๊ฐ€์ ธ์˜ค์ง€ ๋ชปํ•˜๋Š” ํฐ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์„ ์ฟผ๋ฆฌ ๋‘ ๊ฐœ๋กœ ๋‚˜๋ˆ„์–ด left outer join, inner join์œผ๋กœ ๊ฐ๊ฐ ๋‚˜๋ˆ„์–ด ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์ข‹์•„๋ณด์ž…๋‹ˆ๋‹ค. left outer join์˜ ๊ฒฝ์šฐ ์ฒด์ปค๋ฅผ ๋ˆ„๋ฅด์ง€ ์•Š์•˜์ง€๋งŒ ์‚ญ์ œ๋˜์ง€ ์•Š์€ ์ฆ‰ active์ธ ์ฑŒ๋ฆฐ์ง€๋ฅผ ๊ฐ€์ ธ์˜ค๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋ฉฐ inner join์€ ์œ„์—์„œ ๋งŒ๋“  ์ฟผ๋ฆฌ๋กœ ๋™์ž‘ํ•˜๊ฒŒ ๋งŒ๋“ค๋ฉด ๋  ๊ฒƒ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค.

๐ŸŒฟ To-do