mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 16:30:49 +00:00
Caches participant counting process to speed sorting up
This commit is contained in:
parent
cfbc4536c6
commit
3fc247d85c
@ -54,10 +54,13 @@ open class DiscoverChatFeedFilter(val account: Account) : AdditiveFeedFilter<Not
|
|||||||
val followingKeySet = account.selectedUsersFollowList(account.defaultDiscoveryFollowList)
|
val followingKeySet = account.selectedUsersFollowList(account.defaultDiscoveryFollowList)
|
||||||
|
|
||||||
val counter = ParticipantListBuilder()
|
val counter = ParticipantListBuilder()
|
||||||
|
val participantCounts = collection.associate {
|
||||||
|
it to counter.countFollowsThatParticipateOn(it, followingKeySet)
|
||||||
|
}
|
||||||
|
|
||||||
return collection.sortedWith(
|
return collection.sortedWith(
|
||||||
compareBy(
|
compareBy(
|
||||||
{ counter.countFollowsThatParticipateOn(it, followingKeySet) },
|
{ participantCounts[it] },
|
||||||
{ it.createdAt() },
|
{ it.createdAt() },
|
||||||
{ it.idHex }
|
{ it.idHex }
|
||||||
)
|
)
|
||||||
|
@ -44,11 +44,15 @@ open class DiscoverCommunityFeedFilter(val account: Account) : AdditiveFeedFilte
|
|||||||
|
|
||||||
override fun sort(collection: Set<Note>): List<Note> {
|
override fun sort(collection: Set<Note>): List<Note> {
|
||||||
val followingKeySet = account.selectedUsersFollowList(account.defaultDiscoveryFollowList)
|
val followingKeySet = account.selectedUsersFollowList(account.defaultDiscoveryFollowList)
|
||||||
|
|
||||||
val counter = ParticipantListBuilder()
|
val counter = ParticipantListBuilder()
|
||||||
|
val participantCounts = collection.associate {
|
||||||
|
it to counter.countFollowsThatParticipateOn(it, followingKeySet)
|
||||||
|
}
|
||||||
|
|
||||||
return collection.sortedWith(
|
return collection.sortedWith(
|
||||||
compareBy(
|
compareBy(
|
||||||
{ counter.countFollowsThatParticipateOn(it, followingKeySet) },
|
{ participantCounts[it] },
|
||||||
{ it.createdAt() },
|
{ it.createdAt() },
|
||||||
{ it.idHex }
|
{ it.idHex }
|
||||||
)
|
)
|
||||||
|
@ -57,11 +57,14 @@ open class DiscoverLiveFeedFilter(val account: Account) : AdditiveFeedFilter<Not
|
|||||||
val followingKeySet = account.selectedUsersFollowList(account.defaultDiscoveryFollowList)
|
val followingKeySet = account.selectedUsersFollowList(account.defaultDiscoveryFollowList)
|
||||||
|
|
||||||
val counter = ParticipantListBuilder()
|
val counter = ParticipantListBuilder()
|
||||||
|
val participantCounts = collection.associate {
|
||||||
|
it to counter.countFollowsThatParticipateOn(it, followingKeySet)
|
||||||
|
}
|
||||||
|
|
||||||
return collection.sortedWith(
|
return collection.sortedWith(
|
||||||
compareBy(
|
compareBy(
|
||||||
{ convertStatusToOrder((it.event as? LiveActivitiesEvent)?.status()) },
|
{ convertStatusToOrder((it.event as? LiveActivitiesEvent)?.status()) },
|
||||||
{ counter.countFollowsThatParticipateOn(it, followingKeySet) },
|
{ participantCounts[it] },
|
||||||
{ (it.event as? LiveActivitiesEvent)?.starts() ?: it.createdAt() },
|
{ (it.event as? LiveActivitiesEvent)?.starts() ?: it.createdAt() },
|
||||||
{ it.idHex }
|
{ it.idHex }
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user