simplify timeline cleanup (#1932)
* simplify timeline cleanup * fix test
This commit is contained in:
parent
986eb9d542
commit
a6673a6eb2
5 changed files with 26 additions and 35 deletions
|
@ -99,9 +99,8 @@ WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId =
|
|||
AND serverId = :statusId""")
|
||||
abstract fun delete(accountId: Long, statusId: String)
|
||||
|
||||
@Query("""DELETE FROM TimelineStatusEntity WHERE timelineUserId = :accountId
|
||||
AND authorServerId != :accountServerId AND createdAt < :olderThan""")
|
||||
abstract fun cleanup(accountId: Long, accountServerId: String, olderThan: Long)
|
||||
@Query("""DELETE FROM TimelineStatusEntity WHERE createdAt < :olderThan""")
|
||||
abstract fun cleanup(olderThan: Long)
|
||||
|
||||
@Query("""UPDATE TimelineStatusEntity SET poll = :poll
|
||||
WHERE timelineUserId = :accountId AND (serverId = :statusId OR reblogServerId = :statusId)""")
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.keylesspalace.tusky.repository
|
||||
|
||||
import android.text.Spanned
|
||||
import android.text.SpannedString
|
||||
import androidx.core.text.parseAsHtml
|
||||
import androidx.core.text.toHtml
|
||||
|
@ -184,14 +183,10 @@ class TimelineRepositoryImpl(
|
|||
}
|
||||
|
||||
private fun cleanup() {
|
||||
Single.fromCallable {
|
||||
Schedulers.io().scheduleDirect {
|
||||
val olderThan = System.currentTimeMillis() - TimelineRepository.CLEANUP_INTERVAL
|
||||
for (account in accountManager.getAllAccountsOrderedByActive()) {
|
||||
timelineDao.cleanup(account.id, account.accountId, olderThan)
|
||||
}
|
||||
timelineDao.cleanup(olderThan)
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
private fun TimelineStatusWithAccount.toStatus(): TimelineStatus {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue