mirror of https://github.com/usbharu/Hideout.git
feat: ページングに対応
This commit is contained in:
parent
fcd6ebc518
commit
d9bd21661c
|
@ -1,7 +1,9 @@
|
||||||
package dev.usbharu.hideout.core.external.timeline
|
package dev.usbharu.hideout.core.external.timeline
|
||||||
|
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Post
|
import dev.usbharu.hideout.core.domain.model.post.Post
|
||||||
|
import dev.usbharu.hideout.core.domain.model.post.PostId
|
||||||
import dev.usbharu.hideout.core.domain.model.support.page.Page
|
import dev.usbharu.hideout.core.domain.model.support.page.Page
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.page.PaginationList
|
||||||
import dev.usbharu.hideout.core.domain.model.support.timelineobjectdetail.TimelineObjectDetail
|
import dev.usbharu.hideout.core.domain.model.support.timelineobjectdetail.TimelineObjectDetail
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
||||||
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationship
|
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationship
|
||||||
|
@ -21,5 +23,5 @@ interface TimelineStore {
|
||||||
timeline: Timeline,
|
timeline: Timeline,
|
||||||
option: ReadTimelineOption? = null,
|
option: ReadTimelineOption? = null,
|
||||||
page: Page? = null
|
page: Page? = null
|
||||||
): List<TimelineObjectDetail>
|
): PaginationList<TimelineObjectDetail, PostId>
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ class MongoInternalTimelineObjectRepository(
|
||||||
timelineId: TimelineId,
|
timelineId: TimelineId,
|
||||||
internalTimelineObjectOption: InternalTimelineObjectOption?,
|
internalTimelineObjectOption: InternalTimelineObjectOption?,
|
||||||
page: Page?
|
page: Page?
|
||||||
): PaginationList<TimelineObject, TimelineObjectId> {
|
): PaginationList<TimelineObject, PostId> {
|
||||||
val query = Query()
|
val query = Query()
|
||||||
|
|
||||||
if (page?.minId != null) {
|
if (page?.minId != null) {
|
||||||
|
@ -85,8 +85,8 @@ class MongoInternalTimelineObjectRepository(
|
||||||
|
|
||||||
return PaginationList(
|
return PaginationList(
|
||||||
timelineObjects,
|
timelineObjects,
|
||||||
timelineObjects.lastOrNull()?.id,
|
timelineObjects.lastOrNull()?.postId,
|
||||||
timelineObjects.firstOrNull()?.id
|
timelineObjects.firstOrNull()?.postId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import dev.usbharu.hideout.core.domain.model.post.Post
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostId
|
import dev.usbharu.hideout.core.domain.model.post.PostId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
||||||
import dev.usbharu.hideout.core.domain.model.support.page.Page
|
import dev.usbharu.hideout.core.domain.model.support.page.Page
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.page.PaginationList
|
||||||
import dev.usbharu.hideout.core.domain.model.support.timelineobjectdetail.TimelineObjectDetail
|
import dev.usbharu.hideout.core.domain.model.support.timelineobjectdetail.TimelineObjectDetail
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
||||||
|
@ -110,7 +111,7 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
||||||
timelineId: TimelineId,
|
timelineId: TimelineId,
|
||||||
readTimelineOption: ReadTimelineOption?,
|
readTimelineOption: ReadTimelineOption?,
|
||||||
page: Page?
|
page: Page?
|
||||||
): List<TimelineObject>
|
): PaginationList<TimelineObject, PostId>
|
||||||
|
|
||||||
override suspend fun updatePost(post: Post) {
|
override suspend fun updatePost(post: Post) {
|
||||||
val timelineObjectByPostId = getTimelineObjectByPostId(post.id)
|
val timelineObjectByPostId = getTimelineObjectByPostId(post.id)
|
||||||
|
@ -205,7 +206,7 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
||||||
timeline: Timeline,
|
timeline: Timeline,
|
||||||
option: ReadTimelineOption?,
|
option: ReadTimelineOption?,
|
||||||
page: Page?
|
page: Page?
|
||||||
): List<TimelineObjectDetail> {
|
): PaginationList<TimelineObjectDetail, PostId> {
|
||||||
val timelineObjectList = getTimelineObject(timeline.id, option, page)
|
val timelineObjectList = getTimelineObject(timeline.id, option, page)
|
||||||
val lastUpdatedAt = timelineObjectList.minBy { it.lastUpdatedAt }.lastUpdatedAt
|
val lastUpdatedAt = timelineObjectList.minBy { it.lastUpdatedAt }.lastUpdatedAt
|
||||||
|
|
||||||
|
@ -231,31 +232,35 @@ abstract class AbstractTimelineStore(private val idGenerateService: IdGenerateSe
|
||||||
post.id to applyFilters(post, newerFilters)
|
post.id to applyFilters(post, newerFilters)
|
||||||
}
|
}
|
||||||
|
|
||||||
return timelineObjectList.mapNotNull<TimelineObject, TimelineObjectDetail> {
|
return PaginationList(
|
||||||
val timelineUserDetail = userDetails[it.userDetailId] ?: return@mapNotNull null
|
timelineObjectList.mapNotNull<TimelineObject, TimelineObjectDetail> {
|
||||||
val actor = actors[it.postActorId] ?: return@mapNotNull null
|
val timelineUserDetail = userDetails[it.userDetailId] ?: return@mapNotNull null
|
||||||
val post = postMap[it.postId] ?: return@mapNotNull null
|
val actor = actors[it.postActorId] ?: return@mapNotNull null
|
||||||
val reply = postMap[it.replyId]
|
val post = postMap[it.postId] ?: return@mapNotNull null
|
||||||
val replyActor = actors[it.replyActorId]
|
val reply = postMap[it.replyId]
|
||||||
val repost = postMap[it.repostId]
|
val replyActor = actors[it.replyActorId]
|
||||||
val repostActor = actors[it.repostActorId]
|
val repost = postMap[it.repostId]
|
||||||
TimelineObjectDetail.of(
|
val repostActor = actors[it.repostActorId]
|
||||||
timelineObject = it,
|
TimelineObjectDetail.of(
|
||||||
timelineUserDetail = timelineUserDetail,
|
timelineObject = it,
|
||||||
post = post.post,
|
timelineUserDetail = timelineUserDetail,
|
||||||
postActor = actor,
|
post = post.post,
|
||||||
replyPost = reply?.post,
|
postActor = actor,
|
||||||
replyPostActor = replyActor,
|
replyPost = reply?.post,
|
||||||
repostPost = repost?.post,
|
replyPostActor = replyActor,
|
||||||
repostPostActor = repostActor,
|
repostPost = repost?.post,
|
||||||
warnFilter = it.warnFilters + post.filterResults.map {
|
repostPostActor = repostActor,
|
||||||
TimelineObjectWarnFilter(
|
warnFilter = it.warnFilters + post.filterResults.map {
|
||||||
it.filter.id,
|
TimelineObjectWarnFilter(
|
||||||
it.matchedKeyword
|
it.filter.id,
|
||||||
)
|
it.matchedKeyword
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
}
|
)
|
||||||
|
},
|
||||||
|
timelineObjectList.lastOrNull()?.postId,
|
||||||
|
timelineObjectList.firstOrNull()?.postId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract suspend fun getActors(actorIds: List<ActorId>): Map<ActorId, Actor>
|
abstract suspend fun getActors(actorIds: List<ActorId>): Map<ActorId, Actor>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import dev.usbharu.hideout.core.domain.model.post.PostId
|
||||||
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
import dev.usbharu.hideout.core.domain.model.post.PostRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
import dev.usbharu.hideout.core.domain.model.post.Visibility
|
||||||
import dev.usbharu.hideout.core.domain.model.support.page.Page
|
import dev.usbharu.hideout.core.domain.model.support.page.Page
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.page.PaginationList
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineRepository
|
import dev.usbharu.hideout.core.domain.model.timeline.TimelineRepository
|
||||||
|
@ -106,7 +107,7 @@ open class DefaultTimelineStore(
|
||||||
timelineId: TimelineId,
|
timelineId: TimelineId,
|
||||||
readTimelineOption: ReadTimelineOption?,
|
readTimelineOption: ReadTimelineOption?,
|
||||||
page: Page?
|
page: Page?
|
||||||
): List<TimelineObject> {
|
): PaginationList<TimelineObject, PostId> {
|
||||||
return internalTimelineObjectRepository.findByTimelineId(
|
return internalTimelineObjectRepository.findByTimelineId(
|
||||||
timelineId,
|
timelineId,
|
||||||
InternalTimelineObjectOption(
|
InternalTimelineObjectOption(
|
||||||
|
|
|
@ -6,7 +6,6 @@ import dev.usbharu.hideout.core.domain.model.support.page.Page
|
||||||
import dev.usbharu.hideout.core.domain.model.support.page.PaginationList
|
import dev.usbharu.hideout.core.domain.model.support.page.PaginationList
|
||||||
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
import dev.usbharu.hideout.core.domain.model.timeline.TimelineId
|
||||||
import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObject
|
import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObject
|
||||||
import dev.usbharu.hideout.core.domain.model.timelineobject.TimelineObjectId
|
|
||||||
|
|
||||||
interface InternalTimelineObjectRepository {
|
interface InternalTimelineObjectRepository {
|
||||||
suspend fun save(timelineObject: TimelineObject): TimelineObject
|
suspend fun save(timelineObject: TimelineObject): TimelineObject
|
||||||
|
@ -24,7 +23,7 @@ interface InternalTimelineObjectRepository {
|
||||||
timelineId: TimelineId,
|
timelineId: TimelineId,
|
||||||
internalTimelineObjectOption: InternalTimelineObjectOption? = null,
|
internalTimelineObjectOption: InternalTimelineObjectOption? = null,
|
||||||
page: Page? = null
|
page: Page? = null
|
||||||
): PaginationList<TimelineObject, TimelineObjectId>
|
): PaginationList<TimelineObject, PostId>
|
||||||
}
|
}
|
||||||
|
|
||||||
data class InternalTimelineObjectOption(
|
data class InternalTimelineObjectOption(
|
||||||
|
|
Loading…
Reference in New Issue