Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a3c9a37
#250 [Fix] 투표 비율 계산 기준을 preVoteOption에서 postVoteOption으로 수정 (#252)
HYH0804 May 27, 2026
a38c141
#254 [Refactor] 관점 등록/수정 시 GPT 검수 코드 제거 (#256)
HYH0804 Jun 3, 2026
cee2c5d
#255 [Refactor] VoteStatsResponse OptionStat에 title 필드 추가 (#257)
HYH0804 Jun 3, 2026
53533b8
#258 [Feat] 출석체크 API 추가
si-zero Jun 3, 2026
77db7a1
#260 [Feat] 스웨거 어드민/유저 분리
si-zero Jun 4, 2026
a9d4293
[Feat] 알림기능 (#263)
HYH0804 Jun 11, 2026
b5a681b
#262 [Fix] APNs 자격증명 S3 다운로드 시 임시파일 충돌 오류 수정
HYH0804 Jun 11, 2026
d281fa3
#264 [Fix] AdMob SSV 포인트 미적립 버그 수정
si-zero Jun 11, 2026
968d6a3
#262 merge (#266)
HYH0804 Jun 14, 2026
d041631
[Chore] adMob 크롤링 파일 설정: adMob 크롤링 파일 설정 #269
si-zero Jun 16, 2026
ec25882
#270 [Feat] 설정 파일 추가
si-zero Jun 16, 2026
4c45999
[Chore] JWT필터 설정 #271
si-zero Jun 16, 2026
e0c9c1c
#275 [Fix] AdMob SSV 콜백 파라미터 optional 처리 및 서명 검증 활성화
si-zero Jun 18, 2026
ab2cb78
#277 [Fix] AdMob SSV 콜백 URL 검증 요청 처리 실패
si-zero Jun 18, 2026
04d947c
#279 [Fix] AdMob SSV 엔드포인트 검증 실패 시 항상 200 반환
si-zero Jun 18, 2026
d9ea3b5
#283 [Fix] /me/content-activities voteSide null 반환 버그
si-zero Jun 19, 2026
ec27b01
#285 [Feat] content-activities 응답에 option_title 필드 추가
si-zero Jun 20, 2026
6663e7a
#287 [Fix] AdMob SSV 서명 검증 오류로 인한 포인트 미지급 버그
si-zero Jun 24, 2026
39aca84
#289 [Fix] 오늘의 배틀 개수 변경
si-zero Jul 5, 2026
11e2da1
#293 [Fix] 사전투표 철학자 아이콘 미노출
si-zero Jul 5, 2026
aa449f0
#297 [Fix] 댓글 작성 시각이 9시간 전으로 표시되는 버그
si-zero Jul 6, 2026
3259a1a
#301 [Fix] robots.txt 파일 부재로 AdMob app-ads.txt 크롤링 차단
si-zero Jul 6, 2026
e91819b
#305 [Fix] S3 오디오 조각 재다운로드 시 FileAlreadyExistsException으로 TTS 파이프라인 실패
si-zero Jul 6, 2026
d64d5ca
#309 [Fix] JwtFilter 자체 화이트리스트에 /robots.txt 누락으로 401 발생
si-zero Jul 6, 2026
ff16d85
#316 [Fix] 포인트 정책표 대비 코드 불일치 4건 수정
si-zero Jul 7, 2026
f50c749
Merge branch 'main' into dev
si-zero Jul 7, 2026
d9e28a1
#321 [Feat] 알림 미읽음 여부 확인 API 추가
si-zero Jul 7, 2026
4279341
#313 [Hotfix] Railway 배포 환경 FFmpeg 자동 설치 적용 (#320)
jucheonsu Jul 7, 2026
f77048c
#327 [Fix] 알림 전체 읽음 처리 후 모두 읽음 신호가 전달되지 않던 문제 수정
si-zero Jul 13, 2026
99886f9
#331 [Docs] 출석체크 API 명세서를 실제 코드에 맞춰 갱신
si-zero Jul 13, 2026
087b8c0
#333 [Fix] app-ads.txt가 text/html로 응답되어 AdMob 크롤러가 무시하는 문제 수정
si-zero Jul 13, 2026
d33ff1f
#337 [Feat] 인앱 알림 테스트용 API 추가
si-zero Jul 14, 2026
17f35a4
#341 [Fix] 미문서화/중복 포인트 지급 로직 정리
si-zero Jul 15, 2026
acbe078
관리자 페이지를 새 admin-web(Next.js) 앱으로 리다이렉트 (#346)
Roy-wonji Jul 15, 2026
de75bdf
#349 [Feat] admin.web.url env 주입 + 기본값 picke.up.railway.app (#350)
Roy-wonji Jul 15, 2026
9493351
#352 [Fix] JwtFilter 화이트리스트 /api/v1/auth 전체 매칭으로 logout 인증 우회, 500 에러 발생
si-zero Jul 16, 2026
00bfcb3
#356 [Feat] 이용약관/개인정보처리방침 페이지 백엔드 서빙
si-zero Jul 20, 2026
99c936d
#361 [Feat] 관리자용 테스트 계정 로컬 로그인 기능 추가
si-zero Jul 24, 2026
f0a837d
#360 [Refactor] 1인 1관점 제한을 해제하고 1인 다수 관점 등록 허용
si-zero Jul 24, 2026
9fb601f
#366 [Feat] 내 콘텐츠 활동 내역(댓글 탭)에 내가 작성한 관점 포함
si-zero Jul 24, 2026
6a1abde
#370 [Fix] 사전투표만 한 기록도 내 배틀 기록에 노출되는 버그
si-zero Jul 24, 2026
98512e4
Merge branch 'main' into merge/#372
si-zero Jul 24, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ public BattleRecordListResponse getBattleRecords(Integer offset, Integer size, V
List<BattleRecordListResponse.BattleRecordItem> items = votes.stream()
.map(BattleVote -> {
Battle battle = BattleVote.getBattle();
BattleOption selectedOption = BattleVote.getPostVoteOption() != null
? BattleVote.getPostVoteOption() : BattleVote.getPreVoteOption();
BattleOption selectedOption = BattleVote.getPostVoteOption();
VoteSide side = BattleOptionDisplay.voteSide(selectedOption);
String category = categoryMap.get(battle.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,36 @@ public interface BattleVoteRepository extends JpaRepository<BattleVote, Long> {

Optional<BattleVote> findTopByBattleOrderByUpdatedAtDesc(Battle battle);

@Query("SELECT v FROM BattleVote v JOIN FETCH v.battle JOIN FETCH v.preVoteOption " +
"WHERE v.user.id = :userId ORDER BY v.createdAt DESC")
List<BattleVote> findByUserIdOrderByCreatedAtDesc(@Param("userId") Long userId, Pageable pageable);

@Query("SELECT v FROM BattleVote v JOIN FETCH v.battle JOIN FETCH v.preVoteOption " +
"WHERE v.user.id = :userId AND v.preVoteOption.displayOrder = :displayOrder ORDER BY v.createdAt DESC")
List<BattleVote> findByUserIdAndPreVoteOptionDisplayOrderOrderByCreatedAtDesc(
// 내 배틀 기록: 사후투표까지 완료한 기록만 노출
@Query("SELECT v FROM BattleVote v JOIN FETCH v.battle JOIN FETCH v.preVoteOption JOIN FETCH v.postVoteOption " +
"WHERE v.user.id = :userId AND v.postVoteOption IS NOT NULL ORDER BY v.createdAt DESC")
List<BattleVote> findByUserIdAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(@Param("userId") Long userId, Pageable pageable);

@Query("SELECT v FROM BattleVote v JOIN FETCH v.battle JOIN FETCH v.preVoteOption JOIN FETCH v.postVoteOption " +
"WHERE v.user.id = :userId AND v.preVoteOption.displayOrder = :displayOrder AND v.postVoteOption IS NOT NULL ORDER BY v.createdAt DESC")
List<BattleVote> findByUserIdAndPreVoteOptionDisplayOrderAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(
@Param("userId") Long userId, @Param("displayOrder") Integer displayOrder, Pageable pageable);

@Query("SELECT v FROM BattleVote v JOIN FETCH v.battle JOIN FETCH v.preVoteOption " +
"WHERE v.user.id = :userId AND v.preVoteOption.displayOrder <> :displayOrder ORDER BY v.createdAt DESC")
List<BattleVote> findByUserIdAndPreVoteOptionDisplayOrderNotOrderByCreatedAtDesc(
@Query("SELECT v FROM BattleVote v JOIN FETCH v.battle JOIN FETCH v.preVoteOption JOIN FETCH v.postVoteOption " +
"WHERE v.user.id = :userId AND v.preVoteOption.displayOrder <> :displayOrder AND v.postVoteOption IS NOT NULL ORDER BY v.createdAt DESC")
List<BattleVote> findByUserIdAndPreVoteOptionDisplayOrderNotAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(
@Param("userId") Long userId, @Param("displayOrder") Integer displayOrder, Pageable pageable);

@Query("SELECT COUNT(v) FROM BattleVote v WHERE v.user.id = :userId AND v.postVoteOption IS NOT NULL")
long countByUserIdAndPostVoteOptionIsNotNull(@Param("userId") Long userId);

@Query("SELECT COUNT(v) FROM BattleVote v WHERE v.user.id = :userId AND v.preVoteOption.displayOrder = :displayOrder AND v.postVoteOption IS NOT NULL")
long countByUserIdAndPreVoteOptionDisplayOrderAndPostVoteOptionIsNotNull(@Param("userId") Long userId, @Param("displayOrder") Integer displayOrder);

@Query("SELECT COUNT(v) FROM BattleVote v WHERE v.user.id = :userId AND v.preVoteOption.displayOrder <> :displayOrder AND v.postVoteOption IS NOT NULL")
long countByUserIdAndPreVoteOptionDisplayOrderNotAndPostVoteOptionIsNotNull(@Param("userId") Long userId, @Param("displayOrder") Integer displayOrder);

// countTotalParticipation 등 "사전투표만 해도 참여로 집계"하는 통계용 — postVoteOption 필터 없음
long countByUserId(Long userId);

// 오늘의 배틀 무료 참여(일 1회) 제한 체크용: 유저가 오늘 날짜인 배틀에 이미 참여했는지 확인
boolean existsByUserIdAndBattle_TargetDate(Long userId, LocalDate targetDate);

@Query("SELECT COUNT(v) FROM BattleVote v WHERE v.user.id = :userId AND v.preVoteOption.displayOrder = :displayOrder")
long countByUserIdAndPreVoteOptionDisplayOrder(@Param("userId") Long userId, @Param("displayOrder") Integer displayOrder);

@Query("SELECT COUNT(v) FROM BattleVote v WHERE v.user.id = :userId AND v.preVoteOption.displayOrder <> :displayOrder")
long countByUserIdAndPreVoteOptionDisplayOrderNot(@Param("userId") Long userId, @Param("displayOrder") Integer displayOrder);

@Query("SELECT COUNT(v) FROM BattleVote v WHERE v.user.id = :userId " +
"AND v.postVoteOption IS NOT NULL " +
"AND v.preVoteOption <> v.postVoteOption")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ public class VoteQueryService {
public List<BattleVote> findUserVotes(Long userId, int offset, int size, VoteSide voteSide) {
PageRequest pageable = PageRequest.of(offset / size, size);
if (voteSide == VoteSide.PRO) {
return battleVoteRepository.findByUserIdAndPreVoteOptionDisplayOrderOrderByCreatedAtDesc(userId, 1, pageable);
return battleVoteRepository.findByUserIdAndPreVoteOptionDisplayOrderAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(userId, 1, pageable);
}
if (voteSide == VoteSide.CON) {
return battleVoteRepository.findByUserIdAndPreVoteOptionDisplayOrderNotOrderByCreatedAtDesc(userId, 1, pageable);
return battleVoteRepository.findByUserIdAndPreVoteOptionDisplayOrderNotAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(userId, 1, pageable);
}
return battleVoteRepository.findByUserIdOrderByCreatedAtDesc(userId, pageable);
return battleVoteRepository.findByUserIdAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(userId, pageable);
}

public long countUserVotes(Long userId, VoteSide voteSide) {
if (voteSide == VoteSide.PRO) {
return battleVoteRepository.countByUserIdAndPreVoteOptionDisplayOrder(userId, 1);
return battleVoteRepository.countByUserIdAndPreVoteOptionDisplayOrderAndPostVoteOptionIsNotNull(userId, 1);
}
if (voteSide == VoteSide.CON) {
return battleVoteRepository.countByUserIdAndPreVoteOptionDisplayOrderNot(userId, 1);
return battleVoteRepository.countByUserIdAndPreVoteOptionDisplayOrderNotAndPostVoteOptionIsNotNull(userId, 1);
}
return battleVoteRepository.countByUserId(userId);
return battleVoteRepository.countByUserIdAndPostVoteOptionIsNotNull(userId);
}

public long countTotalParticipation(Long userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ void getBattleRecords_returns_paginated_records() {
.user(user)
.battle(battle)
.preVoteOption(optionA)
.postVoteOption(optionA)
.build();
ReflectionTestUtils.setField(vote, "id", generateId());
ReflectionTestUtils.setField(vote, "createdAt", LocalDateTime.now());
Expand All @@ -192,6 +193,7 @@ void getBattleRecords_returns_no_next_when_last_page() {
.user(user)
.battle(battle)
.preVoteOption(optionA)
.postVoteOption(optionA)
.build();
ReflectionTestUtils.setField(vote, "id", generateId());
ReflectionTestUtils.setField(vote, "createdAt", LocalDateTime.now());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.swyp.picke.domain.vote.service;

import com.swyp.picke.domain.user.enums.VoteSide;
import com.swyp.picke.domain.vote.repository.BattleVoteRepository;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class VoteQueryServiceTest {

@Mock
private BattleVoteRepository battleVoteRepository;

@InjectMocks
private VoteQueryService voteQueryService;

@Test
@DisplayName("voteSide 없이 조회하면 사후투표를 완료한 기록만 조회한다")
void findUserVotes_without_voteSide_uses_post_vote_completed_query() {
when(battleVoteRepository.findByUserIdAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(eq(1L), any()))
.thenReturn(List.of());

voteQueryService.findUserVotes(1L, 0, 20, null);

verify(battleVoteRepository).findByUserIdAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(eq(1L), any());
}

@Test
@DisplayName("voteSide=PRO로 조회하면 사후투표를 완료한 PRO 기록만 조회한다")
void findUserVotes_with_pro_uses_post_vote_completed_query() {
when(battleVoteRepository.findByUserIdAndPreVoteOptionDisplayOrderAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(eq(1L), eq(1), any()))
.thenReturn(List.of());

voteQueryService.findUserVotes(1L, 0, 20, VoteSide.PRO);

verify(battleVoteRepository).findByUserIdAndPreVoteOptionDisplayOrderAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(eq(1L), eq(1), any());
}

@Test
@DisplayName("voteSide=CON으로 조회하면 사후투표를 완료한 CON 기록만 조회한다")
void findUserVotes_with_con_uses_post_vote_completed_query() {
when(battleVoteRepository.findByUserIdAndPreVoteOptionDisplayOrderNotAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(eq(1L), eq(1), any()))
.thenReturn(List.of());

voteQueryService.findUserVotes(1L, 0, 20, VoteSide.CON);

verify(battleVoteRepository).findByUserIdAndPreVoteOptionDisplayOrderNotAndPostVoteOptionIsNotNullOrderByCreatedAtDesc(eq(1L), eq(1), any());
}

@Test
@DisplayName("voteSide 없이 카운트하면 사후투표를 완료한 기록만 센다")
void countUserVotes_without_voteSide_uses_post_vote_completed_query() {
when(battleVoteRepository.countByUserIdAndPostVoteOptionIsNotNull(1L)).thenReturn(3L);

long count = voteQueryService.countUserVotes(1L, null);

assertThat(count).isEqualTo(3L);
verify(battleVoteRepository).countByUserIdAndPostVoteOptionIsNotNull(1L);
}

@Test
@DisplayName("총 참여 횟수(countTotalParticipation)는 사전투표만 한 기록도 포함한다")
void countTotalParticipation_includes_pre_vote_only_records() {
when(battleVoteRepository.countByUserId(1L)).thenReturn(5L);

long count = voteQueryService.countTotalParticipation(1L);

assertThat(count).isEqualTo(5L);
verify(battleVoteRepository).countByUserId(1L);
}
}
Loading