From 1fb606f4bbe59d373ac27262bb1323f8acd0db3b Mon Sep 17 00:00:00 2001 From: EnesBaserr Date: Tue, 10 Dec 2024 16:08:32 +0300 Subject: [PATCH] Retrieve tags sorted order by questionCount --- .../programminglanguagesforum/Repositories/TagRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/main/java/com/group1/programminglanguagesforum/Repositories/TagRepository.java b/backend/src/main/java/com/group1/programminglanguagesforum/Repositories/TagRepository.java index da282981..df4999eb 100644 --- a/backend/src/main/java/com/group1/programminglanguagesforum/Repositories/TagRepository.java +++ b/backend/src/main/java/com/group1/programminglanguagesforum/Repositories/TagRepository.java @@ -14,6 +14,10 @@ @Repository public interface TagRepository extends JpaRepository { List findAllByIdIn(List ids); + @Query("SELECT t FROM Tag t " + + "JOIN Question q ON t MEMBER OF q.tags " + + "GROUP BY t.id " + + "ORDER BY COUNT(q.id) DESC") Page findTagsByTagNameContainingIgnoreCase(String tagName, Pageable pageable); @Query("SELECT t FROM Tag t JOIN t.followers u WHERE u.id = :userId")