Skip to content

Commit

Permalink
Fix: 필요없는 JPQL 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
Hawardshin committed Oct 7, 2024
1 parent 5d88a85 commit de0814c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ private void updateStreakData(SearchHistory history, YearMonth dateYM, String pu
matchStreakRepository.save(matchDateStreak);
} catch (Exception e) {
log.error("Http Error: " + e.getMessage());
searchHistoryRepository.updateLastSuccessDateByHistoryId(history.getId(), i);
history.setLastSuccessDay(i);
searchHistoryRepository.save(history);
return;
}
}

if (dateYM.equals(YearMonth.now())) { // 만약 이번달인 경우
searchHistoryRepository.updateLastSuccessDateByHistoryId(history.getId(), YearMonthToEpochUtil.getNowDay());
history.setLastSuccessDay(YearMonthToEpochUtil.getNowDay());
} else {
searchHistoryRepository.updateLastSuccessDateByHistoryId(history.getId(),
31);
searchHistoryRepository.updateIsDoneByHistoryId(history.getId(), true);
history.setLastSuccessDay(dateYM.lengthOfMonth());
history.setDone(true);
}
searchHistoryRepository.save(history);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class SearchHistory extends BaseEntity {

@Column(name = "last_success_day", nullable = false)
@ColumnDefault("0")
@Setter
private int lastSuccessDay; // 마지막으로 api 콜이 성공한 날짜.

@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,10 @@
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import jakarta.transaction.Transactional;
import mejai.mejaigg.searchhistory.domain.SearchHistory;
import mejai.mejaigg.summoner.domain.Summoner;

public interface SearchHistoryRepository extends JpaRepository<SearchHistory, Long> {
Optional<SearchHistory> findBySummonerAndDate(Summoner summoner, YearMonth date);

@Transactional
@Modifying
@Query("UPDATE SearchHistory sh SET sh.done = :isDone WHERE sh.id = :historyId")
void updateIsDoneByHistoryId(Long historyId, boolean isDone);

@Transactional
@Modifying
@Query("UPDATE SearchHistory sh SET sh.lastSuccessDay = :lastSuccessDay WHERE sh.id = :historyId")
void updateLastSuccessDateByHistoryId(Long historyId, int lastSuccessDay);
}

0 comments on commit de0814c

Please sign in to comment.