feat: ホームタイムラインが読めるように

This commit is contained in:
usbharu 2024-08-16 15:10:53 +09:00
parent e1787423e8
commit d53cdca9e5
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
3 changed files with 8 additions and 9 deletions

View File

@ -8,6 +8,5 @@ interface FilterRepository {
suspend fun findByFilterKeywordId(filterKeywordId: FilterKeywordId): Filter?
suspend fun findByFilterId(filterId: FilterId): Filter?
suspend fun findByUserDetailId(userDetailId: UserDetailId): List<Filter>
}

View File

@ -59,22 +59,22 @@ class ExposedFilterRepository(private val filterQueryMapper: QueryMapper<Filter>
Filters.deleteWhere { id eq filter.id.id }
}
override suspend fun findByFilterKeywordId(filterKeywordId: FilterKeywordId): Filter? {
override suspend fun findByFilterKeywordId(filterKeywordId: FilterKeywordId): Filter? = query {
val filterId = FilterKeywords
.selectAll()
.where { FilterKeywords.id eq filterKeywordId.id }
.firstOrNull()?.get(FilterKeywords.filterId) ?: return null
.firstOrNull()?.get(FilterKeywords.filterId) ?: return@query null
val where = Filters.selectAll().where { Filters.id eq filterId }
return filterQueryMapper.map(where).firstOrNull()
return@query filterQueryMapper.map(where).firstOrNull()
}
override suspend fun findByFilterId(filterId: FilterId): Filter? {
override suspend fun findByFilterId(filterId: FilterId): Filter? = query {
val where = Filters.selectAll().where { Filters.id eq filterId.id }
return filterQueryMapper.map(where).firstOrNull()
return@query filterQueryMapper.map(where).firstOrNull()
}
override suspend fun findByUserDetailId(userDetailId: UserDetailId): List<Filter> {
return Filters.selectAll().where { Filters.userId eq userDetailId.id }.let(filterQueryMapper::map)
override suspend fun findByUserDetailId(userDetailId: UserDetailId): List<Filter> = query {
return@query Filters.selectAll().where { Filters.userId eq userDetailId.id }.let(filterQueryMapper::map)
}
companion object {

View File

@ -67,7 +67,7 @@ open class DefaultTimelineStore(
}
override suspend fun getNewerFilters(userDetailId: UserDetailId, lastUpdateAt: Instant): List<Filter> {
TODO("Not yet implemented")
return filterRepository.findByUserDetailId(userDetailId)
}
override suspend fun applyFilters(post: Post, filters: List<Filter>): FilteredPost {