Sha256: c66bed93ced91d9477b2ae46bbf94676497233d91e1cff08bf23d980aaea530f

Contents?: true

Size: 1.24 KB

Versions: 24

Compression:

Stored size: 1.24 KB

Contents

module Workarea
  module Search
    class Admin
      module Releasable
        def facets
          super.merge(
            upcoming_changes: upcoming_release_ids_with_changesets,
            active_by_segment: active_segment_ids
          )
        end

        def status
          if model.active?
            'active'
          else
            'inactive'
          end
        end

        private

        def upcoming_release_ids_with_changesets
          (model_changesets + content_changesets).map(&:release_id)
        end

        def model_changesets
          model.changesets.any_in(release_id: upcoming_release_ids)
        end

        def content_changesets
          return [] unless content.present?
          content.changesets.any_in(release_id: upcoming_release_ids)
        end

        def upcoming_release_ids
          @upcoming_release_ids ||= Workarea::Release.upcoming.map(&:id)
        end

        def content
          return unless model.is_a?(Contentable)
          @content ||= Workarea::Content.for(model)
        end

        def active_segment_ids
          result = model.active_segment_ids_with_children +
            (content&.active_segment_ids_with_children || [])

          result.uniq
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
workarea-core-3.5.23 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.22 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.21 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.20 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.19 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.18 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.17 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.16 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.15 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.14 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.13 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.12 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.11 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.10 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.9 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.8 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.7 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.6 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.5 app/models/workarea/search/admin/releasable.rb
workarea-core-3.5.4 app/models/workarea/search/admin/releasable.rb