Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions app/models/card/entropic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,10 @@ module Card::Entropic
# queries with a single constant cutoff, so `account_id = ? AND
# last_active_at <= ?` rides the existing index instead of computing the
# threshold per row across every card in the system.
#
# The account+board+status index is pinned with use_index so this background
# sweep's plan is independent of InnoDB statistics freshness: for a large
# account's selective board group the optimizer can otherwise flip to an
# account-wide scan when stats go stale, turning a ~30ms query into a
# multi-second one. Pinning caps the tail; the negligible cost on broad
# board groups is irrelevant for a background job.
def auto_postpone_all_due(as_of: Time.now)
Account.find_each do |account|
account.boards.includes(:entropy).group_by(&:auto_postpone_period).each do |period, boards|
account.cards.active
.use_index(:index_cards_on_account_id_and_board_id_and_status)
.where(board_id: boards.map(&:id))
.where(last_active_at: ..(as_of - period))
.find_each do |card|
Expand Down