mirror of https://github.com/usbharu/Hideout.git
Merge pull request #83 from usbharu/bugfix/fix-timeline
fix: タイムラインが読み込まれないのを修正
This commit is contained in:
commit
65ad6409f2
|
@ -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.query.mastodon.StatusQueryService
|
||||
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.query.Criteria
|
||||
import org.springframework.data.mongodb.core.query.Query
|
||||
|
@ -26,6 +27,7 @@ class MongoGenerateTimelineService(
|
|||
limit: Int
|
||||
): List<Status> {
|
||||
val query = Query()
|
||||
|
||||
if (forUserId != null) {
|
||||
val criteria = Criteria.where("userId").`is`(forUserId)
|
||||
query.addCriteria(criteria)
|
||||
|
@ -43,7 +45,10 @@ class MongoGenerateTimelineService(
|
|||
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) })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue