-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
src/main/java/com/mz/ihangbot/keyWord/repository/KeyWordRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
package com.mz.ihangbot.keyWord.repository; | ||
|
||
import com.mz.ihangbot.keyWord.domain.KeyWord; | ||
import com.mz.ihangbot.member.domain.Member; | ||
import com.mz.ihangbot.report.dto.KeyWordReportResponseDTO; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface KeyWordRepository extends JpaRepository<KeyWord, Long> { | ||
|
||
@Query(value = "select new com.mz.ihangbot.report.dto.KeyWordReportResponseDTO(result.kw, result.cnt) from (select k.keyword as kw, SUM(k.count) as cnt from KeyWord k where :username = k.member.username and :aWeekAgo <= k.date group by k.keyword) as result order by result.cnt DESC limit 5") | ||
List<KeyWordReportResponseDTO> getKeyWords(@Param("username") String username, @Param("aWeekAgo") Date aWeekAgo); | ||
|
||
|
||
@Query(value = "select k from KeyWord k where :username = k.member.username and k.date >= :aWeekAgo") | ||
List<KeyWord> findAllByUsernameAndDate(@Param("username") String username, @Param("aWeekAgo") Date aWeekAgo); | ||
|
||
@Query(value = "select k from KeyWord k where :username = k.member.username and k.date >= :aWeekAgo and k.keyword = :keyword") | ||
Optional<KeyWord> findByUsernameAndDateAndKeyWord(@Param("username") String username, @Param("aWeekAgo") Date aWeekAgo, @Param("keyword") String keyword); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters