Forced ordering of search results
This commit is contained in:
parent
0d325506e0
commit
90bb712bc3
@ -62,11 +62,11 @@ class ImageController
|
||||
tagData.size != distinctTags.size -> null // Error if an invalid tag was supplied
|
||||
tagData.size == 1 -> {
|
||||
// Simpler query for single tag searches
|
||||
val result = imageRepository.findAllByTagsContaining(tagData[0], page)
|
||||
val result = imageRepository.findAllByTagsContainingOrderById(tagData[0], page)
|
||||
if (result.isEmpty) null else result
|
||||
}
|
||||
else -> {
|
||||
val result = imageRepository.findByTags(tagData, tagData.size.toLong(), page)
|
||||
val result = imageRepository.findByTagsOrderById(tagData, tagData.size.toLong(), page)
|
||||
if (result.isEmpty) null else result
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,14 @@ interface RoleRepository : CrudRepository<Role, Long>
|
||||
|
||||
interface ImageRepository : JpaRepository<Image, Long> {
|
||||
//@Query("select i from Image i join i.tags t where t in ?1 group by i.id having count(i.id) = ?2")
|
||||
@Suppress("SqlResolve")
|
||||
@Query(
|
||||
value = "select * from booru.image i where i.id in (select image_id from booru.tag_image ti where ti.tag_id in ?1 group by ti.image_id having count(ti.image_id) = ?2)",
|
||||
value = "select * from booru.image i where i.id in (select image_id from booru.tag_image ti where ti.tag_id in ?1 group by ti.image_id having count(ti.image_id) = ?2) order by i.id",
|
||||
nativeQuery = true
|
||||
)
|
||||
fun findByTags(tagIDs: List<Tag>, tagCount: Long, pageable: Pageable): Page<Image>
|
||||
fun findByTagsOrderById(tagIDs: List<Tag>, tagCount: Long, pageable: Pageable): Page<Image>
|
||||
|
||||
fun findAllByTagsContaining(tag: Tag, pageable: Pageable): Page<Image>
|
||||
fun findAllByTagsContainingOrderById(tag: Tag, pageable: Pageable): Page<Image>
|
||||
}
|
||||
|
||||
interface TagRepository : CrudRepository<Tag, Long> {
|
||||
|
Loading…
Reference in New Issue
Block a user