-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(backend): tag service not returning any tags without questions
- Loading branch information
Showing
4 changed files
with
268 additions
and
233 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
12 changes: 7 additions & 5 deletions
12
backend/src/main/java/com/group1/programminglanguagesforum/Repositories/TagRepository.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,25 +1,27 @@ | ||
package com.group1.programminglanguagesforum.Repositories; | ||
|
||
import java.util.List; | ||
|
||
import com.group1.programminglanguagesforum.Entities.Tag; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import com.group1.programminglanguagesforum.Entities.Tag; | ||
|
||
@Repository | ||
public interface TagRepository extends JpaRepository<Tag,Long> { | ||
public interface TagRepository extends JpaRepository<Tag, Long> { | ||
List<Tag> findAllByIdIn(List<Long> ids); | ||
|
||
@Query("SELECT t FROM Tag t " + | ||
"JOIN Question q ON t MEMBER OF q.tags " + | ||
"LEFT JOIN Question q ON t MEMBER OF q.tags " + | ||
"WHERE LOWER(t.tagName) LIKE LOWER(CONCAT('%', :tagName, '%')) " + | ||
"GROUP BY t.id " + | ||
"ORDER BY COUNT(q.id) DESC") | ||
|
||
Page<Tag> findTagsByTagNameContainingIgnoreCase(String tagName, Pageable pageable); | ||
|
||
@Query("SELECT t FROM Tag t JOIN t.followers u WHERE u.id = :userId") | ||
List<Tag> findTagByFollowers(@Param("userId") Long userId); | ||
} |
Oops, something went wrong.