mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 16:41:36 +01:00
Define constants for sampling sizes in AccountReachFinder
(#32805)
This commit is contained in:
parent
1f85ca2b0e
commit
ea6d3ca8c1
1 changed files with 22 additions and 4 deletions
|
@ -1,6 +1,10 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AccountReachFinder
|
class AccountReachFinder
|
||||||
|
RECENT_LIMIT = 2_000
|
||||||
|
STATUS_LIMIT = 200
|
||||||
|
STATUS_SINCE = 2.days
|
||||||
|
|
||||||
def initialize(account)
|
def initialize(account)
|
||||||
@account = account
|
@account = account
|
||||||
end
|
end
|
||||||
|
@ -20,13 +24,27 @@ class AccountReachFinder
|
||||||
end
|
end
|
||||||
|
|
||||||
def recently_mentioned_inboxes
|
def recently_mentioned_inboxes
|
||||||
cutoff_id = Mastodon::Snowflake.id_at(2.days.ago, with_random: false)
|
Account
|
||||||
recent_statuses = @account.statuses.recent.where(id: cutoff_id...).limit(200)
|
.joins(:mentions)
|
||||||
|
.where(mentions: { status: recent_statuses })
|
||||||
Account.joins(:mentions).where(mentions: { status: recent_statuses }).inboxes.take(2000)
|
.inboxes
|
||||||
|
.take(RECENT_LIMIT)
|
||||||
end
|
end
|
||||||
|
|
||||||
def relay_inboxes
|
def relay_inboxes
|
||||||
Relay.enabled.pluck(:inbox_url)
|
Relay.enabled.pluck(:inbox_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def oldest_status_id
|
||||||
|
Mastodon::Snowflake
|
||||||
|
.id_at(STATUS_SINCE.ago, with_random: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def recent_statuses
|
||||||
|
@account
|
||||||
|
.statuses
|
||||||
|
.recent
|
||||||
|
.where(id: oldest_status_id...)
|
||||||
|
.limit(STATUS_LIMIT)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue