mirror of https://github.com/usbharu/Hideout.git
fix: タイムラインが読み込まれないのを修正
This commit is contained in:
parent
3babce2f0c
commit
664b213346
|
@ -4,6 +4,7 @@ import dev.usbharu.hideout.domain.mastodon.model.generated.Status
|
||||||
import dev.usbharu.hideout.domain.model.hideout.entity.Timeline
|
import dev.usbharu.hideout.domain.model.hideout.entity.Timeline
|
||||||
import dev.usbharu.hideout.query.mastodon.StatusQueryService
|
import dev.usbharu.hideout.query.mastodon.StatusQueryService
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||||||
|
import org.springframework.data.domain.Sort
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate
|
import org.springframework.data.mongodb.core.MongoTemplate
|
||||||
import org.springframework.data.mongodb.core.query.Criteria
|
import org.springframework.data.mongodb.core.query.Criteria
|
||||||
import org.springframework.data.mongodb.core.query.Query
|
import org.springframework.data.mongodb.core.query.Query
|
||||||
|
@ -26,6 +27,7 @@ class MongoGenerateTimelineService(
|
||||||
limit: Int
|
limit: Int
|
||||||
): List<Status> {
|
): List<Status> {
|
||||||
val query = Query()
|
val query = Query()
|
||||||
|
|
||||||
if (forUserId != null) {
|
if (forUserId != null) {
|
||||||
val criteria = Criteria.where("userId").`is`(forUserId)
|
val criteria = Criteria.where("userId").`is`(forUserId)
|
||||||
query.addCriteria(criteria)
|
query.addCriteria(criteria)
|
||||||
|
@ -43,7 +45,10 @@ class MongoGenerateTimelineService(
|
||||||
query.addCriteria(criteria)
|
query.addCriteria(criteria)
|
||||||
}
|
}
|
||||||
|
|
||||||
val timelines = mongoTemplate.find(query.limit(limit), Timeline::class.java)
|
query.limit(limit)
|
||||||
|
query.with(Sort.by(Sort.Direction.DESC, "createdAt"))
|
||||||
|
|
||||||
|
val timelines = mongoTemplate.find(query, Timeline::class.java)
|
||||||
|
|
||||||
return statusQueryService.findByPostIds(timelines.flatMap { setOfNotNull(it.postId, it.replyId, it.repostId) })
|
return statusQueryService.findByPostIds(timelines.flatMap { setOfNotNull(it.postId, it.replyId, it.repostId) })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue