mirror of https://github.com/usbharu/Hideout.git
fix: 修正した実装に切り替え
This commit is contained in:
parent
97f773144a
commit
3a6271a872
|
@ -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.Page
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
|
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.pagination
|
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.AbstractRepository
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
|
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
|
||||||
import org.jetbrains.exposed.dao.id.LongIdTable
|
import org.jetbrains.exposed.dao.id.LongIdTable
|
||||||
|
@ -87,12 +88,12 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
||||||
.and(Relationships.ignoreFollowRequestFromTarget.eq(ignoreFollowRequest))
|
.and(Relationships.ignoreFollowRequestFromTarget.eq(ignoreFollowRequest))
|
||||||
}
|
}
|
||||||
|
|
||||||
val resultRowList = query.pagination(page, Relationships.id).toList()
|
val resultRowList = query.withPagination(page, Relationships.id)
|
||||||
|
|
||||||
return@query PaginationList(
|
return@query PaginationList(
|
||||||
query.map { it.toRelationships() },
|
resultRowList.map { it.toRelationships() },
|
||||||
resultRowList.lastOrNull()?.getOrNull(Relationships.id)?.value,
|
resultRowList.next?.value,
|
||||||
resultRowList.firstOrNull()?.getOrNull(Relationships.id)?.value
|
resultRowList.prev?.value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,12 +106,12 @@ class RelationshipRepositoryImpl : RelationshipRepository, AbstractRepository()
|
||||||
Relationships.actorId.eq(actorId).and(Relationships.muting.eq(muting))
|
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(
|
return@query PaginationList(
|
||||||
query.map { it.toRelationships() },
|
resultRowList.map { it.toRelationships() },
|
||||||
resultRowList.lastOrNull()?.getOrNull(Relationships.id)?.value,
|
resultRowList.next?.value,
|
||||||
resultRowList.firstOrNull()?.getOrNull(Relationships.id)?.value
|
resultRowList.prev?.value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.Page
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
|
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.pagination
|
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.core.infrastructure.exposedrepository.Timelines
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.Status
|
import dev.usbharu.hideout.domain.mastodon.model.generated.Status
|
||||||
import dev.usbharu.hideout.mastodon.interfaces.api.status.StatusQuery
|
import dev.usbharu.hideout.mastodon.interfaces.api.status.StatusQuery
|
||||||
|
@ -31,9 +32,8 @@ class ExposedGenerateTimelineService(private val statusQueryService: StatusQuery
|
||||||
if (localOnly) {
|
if (localOnly) {
|
||||||
query.andWhere { Timelines.isLocal eq true }
|
query.andWhere { Timelines.isLocal eq true }
|
||||||
}
|
}
|
||||||
query.pagination(page, Timelines.id)
|
val result = query.withPagination(page, Timelines.id)
|
||||||
val result = query
|
|
||||||
.orderBy(Timelines.createdAt, SortOrder.DESC)
|
|
||||||
|
|
||||||
val statusQueries = result.map {
|
val statusQueries = result.map {
|
||||||
StatusQuery(
|
StatusQuery(
|
||||||
|
|
|
@ -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.Page
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
|
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.pagination
|
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.emoji.CustomEmoji
|
||||||
import dev.usbharu.hideout.core.domain.model.media.toMediaAttachments
|
import dev.usbharu.hideout.core.domain.model.media.toMediaAttachments
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedrepository.*
|
import dev.usbharu.hideout.core.infrastructure.exposedrepository.*
|
||||||
|
@ -71,8 +72,6 @@ class StatusQueryServiceImpl : StatusQueryService {
|
||||||
.leftJoin(Media)
|
.leftJoin(Media)
|
||||||
.select { Posts.actorId eq accountId }
|
.select { Posts.actorId eq accountId }
|
||||||
|
|
||||||
query.pagination(page, Posts.id)
|
|
||||||
|
|
||||||
if (onlyMedia) {
|
if (onlyMedia) {
|
||||||
query.andWhere { PostsMedia.mediaId.isNotNull() }
|
query.andWhere { PostsMedia.mediaId.isNotNull() }
|
||||||
}
|
}
|
||||||
|
@ -88,7 +87,9 @@ class StatusQueryServiceImpl : StatusQueryService {
|
||||||
query.andWhere { Posts.visibility inList listOf(public.ordinal, unlisted.ordinal) }
|
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 { it.value }
|
||||||
.map {
|
.map {
|
||||||
toStatus(it.first()).copy(
|
toStatus(it.first()).copy(
|
||||||
|
|
|
@ -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.Page
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
|
import dev.usbharu.hideout.application.infrastructure.exposed.PaginationList
|
||||||
import dev.usbharu.hideout.application.infrastructure.exposed.pagination
|
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.AbstractRepository
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Timelines
|
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Timelines
|
||||||
import dev.usbharu.hideout.mastodon.domain.model.MastodonNotification
|
import dev.usbharu.hideout.mastodon.domain.model.MastodonNotification
|
||||||
|
@ -71,12 +72,9 @@ class ExposedMastodonNotificationRepository : MastodonNotificationRepository, Ab
|
||||||
val query = MastodonNotifications.select {
|
val query = MastodonNotifications.select {
|
||||||
MastodonNotifications.userId eq loginUser
|
MastodonNotifications.userId eq loginUser
|
||||||
}
|
}
|
||||||
val result = query
|
val result = query.withPagination(page, MastodonNotifications.id)
|
||||||
.pagination(page, MastodonNotifications.id)
|
|
||||||
.orderBy(Timelines.createdAt, SortOrder.DESC)
|
|
||||||
|
|
||||||
val notifications = result.map { it.toMastodonNotification() }
|
return@query PaginationList(result.map { it.toMastodonNotification() }, result.next, result.prev)
|
||||||
return@query PaginationList(notifications, notifications.lastOrNull()?.id, notifications.firstOrNull()?.id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun deleteByUserId(userId: Long) {
|
override suspend fun deleteByUserId(userId: Long) {
|
||||||
|
|
Loading…
Reference in New Issue