Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/main/resources/mappers/challenge/ChallengeMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,11 @@
e.description,
e.expenditure_date as expenditureDate
FROM expenditure e
JOIN (
SELECT user_id, MAX(end_date) as latest_end_date
FROM user_challenge
WHERE user_id = #{userId}
GROUP BY user_id
) uc ON e.user_id = uc.user_id
AND DATE(e.expenditure_date) = DATE(uc.latest_end_date)
JOIN challenge c ON c.challenge_id = #{challengeId}
WHERE e.user_id = #{userId}
AND e.category_id = #{challengeId}
AND EXISTS (
SELECT 1
FROM user_challenge uc2
WHERE uc2.user_id = #{userId}
AND uc2.challenge_id = #{challengeId}
)
AND e.category_id = c.category_id
AND e.expenditure_date >= DATE_SUB(NOW(), INTERVAL 1 DAY)
ORDER BY e.expenditure_date DESC
LIMIT 10
</select>
</mapper>