fix: 修正した実装に切り替え

This commit is contained in:
usbharu 2024-01-30 22:54:39 +09:00
parent 97f773144a
commit 3a6271a872
4 changed files with 19 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package dev.usbharu.hideout.core.domain.model.relationship
import dev.usbharu.hideout.application.infrastructure.exposed.Page
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
import dev.usbharu.hideout.application.infrastructure.exposed.pagination
import dev.usbharu.hideout.application.infrastructure.exposed.withPagination
import dev.usbharu.hideout.core.infrastructure.exposedrepository.AbstractRepository
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
import org.jetbrains.exposed.dao.id.LongIdTable
@ -87,12 +88,12 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
.and(Relationships.ignoreFollowRequestFromTarget.eq(ignoreFollowRequest))
}
val resultRowList = query.pagination(page, Relationships.id).toList()
val resultRowList = query.withPagination(page, Relationships.id)
return@query PaginationList(
query.map { it.toRelationships() },
resultRowList.lastOrNull()?.getOrNull(Relationships.id)?.value,
resultRowList.firstOrNull()?.getOrNull(Relationships.id)?.value
resultRowList.map { it.toRelationships() },
resultRowList.next?.value,
resultRowList.prev?.value
)
}
@ -105,12 +106,12 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
Relationships.actorId.eq(actorId).and(Relationships.muting.eq(muting))
}
val resultRowList = query.pagination(page, Relationships.id).toList()
val resultRowList = query.withPagination(page, Relationships.id)
return@query PaginationList(
query.map { it.toRelationships() },
resultRowList.lastOrNull()?.getOrNull(Relationships.id)?.value,
resultRowList.firstOrNull()?.getOrNull(Relationships.id)?.value
resultRowList.map { it.toRelationships() },
resultRowList.next?.value,
resultRowList.prev?.value
)
}

View File

@ -3,6 +3,7 @@ package dev.usbharu.hideout.core.service.timeline
import dev.usbharu.hideout.application.infrastructure.exposed.Page
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
import dev.usbharu.hideout.application.infrastructure.exposed.pagination
import dev.usbharu.hideout.application.infrastructure.exposed.withPagination
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Timelines
import dev.usbharu.hideout.domain.mastodon.model.generated.Status
import dev.usbharu.hideout.mastodon.interfaces.api.status.StatusQuery
@ -31,9 +32,8 @@ class ExposedGenerateTimelineService(private val statusQueryService: StatusQuery
if (localOnly) {
query.andWhere { Timelines.isLocal eq true }
}
query.pagination(page, Timelines.id)
val result = query
.orderBy(Timelines.createdAt, SortOrder.DESC)
val result = query.withPagination(page, Timelines.id)
val statusQueries = result.map {
StatusQuery(

View File

@ -3,6 +3,7 @@ package dev.usbharu.hideout.mastodon.infrastructure.exposedquery
import dev.usbharu.hideout.application.infrastructure.exposed.Page
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
import dev.usbharu.hideout.application.infrastructure.exposed.pagination
import dev.usbharu.hideout.application.infrastructure.exposed.withPagination
import dev.usbharu.hideout.core.domain.model.emoji.CustomEmoji
import dev.usbharu.hideout.core.domain.model.media.toMediaAttachments
import dev.usbharu.hideout.core.infrastructure.exposedrepository.*
@ -71,8 +72,6 @@ class StatusQueryServiceImpl : StatusQueryService {
.leftJoin(Media)
.select { Posts.actorId eq accountId }
query.pagination(page, Posts.id)
if (onlyMedia) {
query.andWhere { PostsMedia.mediaId.isNotNull() }
}
@ -88,7 +87,9 @@ class StatusQueryServiceImpl : StatusQueryService {
query.andWhere { Posts.visibility inList listOf(public.ordinal, unlisted.ordinal) }
}
val pairs = query.groupBy { it[Posts.id] }
val pairs = query
.withPagination(page,Posts.id)
.groupBy { it[Posts.id] }
.map { it.value }
.map {
toStatus(it.first()).copy(

View File

@ -3,6 +3,7 @@ package dev.usbharu.hideout.mastodon.infrastructure.exposedrepository
import dev.usbharu.hideout.application.infrastructure.exposed.Page
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
import dev.usbharu.hideout.application.infrastructure.exposed.pagination
import dev.usbharu.hideout.application.infrastructure.exposed.withPagination
import dev.usbharu.hideout.core.infrastructure.exposedrepository.AbstractRepository
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Timelines
import dev.usbharu.hideout.mastodon.domain.model.MastodonNotification
@ -71,12 +72,9 @@ class ExposedMastodonNotificationRepository : MastodonNotificationRepository, Ab
val query = MastodonNotifications.select {
MastodonNotifications.userId eq loginUser
}
val result = query
.pagination(page, MastodonNotifications.id)
.orderBy(Timelines.createdAt, SortOrder.DESC)
val result = query.withPagination(page, MastodonNotifications.id)
val notifications = result.map { it.toMastodonNotification() }
return@query PaginationList(notifications, notifications.lastOrNull()?.id, notifications.firstOrNull()?.id)
return@query PaginationList(result.map { it.toMastodonNotification() }, result.next, result.prev)
}
override suspend fun deleteByUserId(userId: Long) {