diff --git a/app/controllers/cards_controller.rb b/app/controllers/cards_controller.rb index d535f26d9..adfa4394c 100644 --- a/app/controllers/cards_controller.rb +++ b/app/controllers/cards_controller.rb @@ -9,9 +9,9 @@ class CardsController < ApplicationController PAGE_SIZE = 50 def index - @considering = page_and_filter_for @filter.with(engagement_status: "considering", indexed_by: "latest"), per_page: PAGE_SIZE - @doing = page_and_filter_for @filter.with(engagement_status: "doing", indexed_by: "latest"), per_page: PAGE_SIZE - @closed = page_and_filter_for(@filter.with(indexed_by: "closed"), per_page: PAGE_SIZE) { |cards| cards.recently_closed_first } + @considering = page_and_filter_for @filter.with(engagement_status: "considering"), per_page: PAGE_SIZE + @doing = page_and_filter_for @filter.with(engagement_status: "doing"), per_page: PAGE_SIZE + @closed = page_and_filter_for_closed_cards end def create @@ -41,6 +41,14 @@ class CardsController < ApplicationController end private + def page_and_filter_for_closed_cards + if @filter.indexed_by.stalled? + page_and_filter_for(@filter, per_page: PAGE_SIZE) { |cards| cards.recently_closed_first } + else + page_and_filter_for(@filter.with(indexed_by: "closed"), per_page: PAGE_SIZE) { |cards| cards.recently_closed_first } + end + end + def set_card @card = @collection.cards.find params[:id] end diff --git a/app/models/card.rb b/app/models/card.rb index 5d4d357f1..c3d27b956 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -23,7 +23,7 @@ class Card < ApplicationRecord when "newest" then reverse_chronologically when "oldest" then chronologically when "latest" then latest - when "stalled" then chronologically + when "stalled" then stalled.chronologically when "closed" then closed end end diff --git a/app/models/card/stallable.rb b/app/models/card/stallable.rb index e460cd030..6a50c09b5 100644 --- a/app/models/card/stallable.rb +++ b/app/models/card/stallable.rb @@ -7,13 +7,13 @@ module Card::Stallable has_one :activity_spike, class_name: "Card::ActivitySpike", dependent: :destroy scope :with_activity_spikes, -> { joins(:activity_spike) } - scope :stalled, -> { with_activity_spikes.where(updated_at: ..STALLED_AFTER_LAST_SPIKE_PERIOD.ago) } + scope :stalled, -> { open.with_activity_spikes.where("card_activity_spikes.updated_at": ..STALLED_AFTER_LAST_SPIKE_PERIOD.ago) } after_update_commit :detect_activity_spikes_later, if: :saved_change_to_last_active_at? end def stalled? - last_activity_spike_at < STALLED_AFTER_LAST_SPIKE_PERIOD.ago if activity_spike.present? + open? && last_activity_spike_at < STALLED_AFTER_LAST_SPIKE_PERIOD.ago if activity_spike.present? end def last_activity_spike_at diff --git a/app/models/command/ai/translator.rb b/app/models/command/ai/translator.rb index 75013214f..4d85a4e8a 100644 --- a/app/models/command/ai/translator.rb +++ b/app/models/command/ai/translator.rb @@ -54,7 +54,9 @@ class Command::Ai::Translator * **terms**: Array of keywords (split individually, e.g., ["some", "term"]). Avoid redundancy. * **indexed_by**: "newest", "oldest", "latest", "stalled", "closed". * "closed": completed cards. - * "newest": by creation date, "latest": by update date. + * "newest": by creation date + * "latest": by update date. + * "stalled": cards that stopped showing activity after an initial activity spike. * **assignee_ids**: Array of assignee names. * **assignment_status**: "unassigned". * **engagement_status**: "considering" or "doing".