Sha256: d6cf4f14800cbbbe756cfef539bf32567d1b8755dee5e030add3e8bcfa6bdc53

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

require 'pact_broker/ui/controllers/base_controller'
require 'pact_broker/ui/view_models/index_items'
require 'haml'

module PactBroker
  module UI
    module Controllers
      class Index < Base
        include PactBroker::Services

        get "/" do
          set_headers
          tags = nil
          if params[:tags]
            tags = params[:tags] == 'true' ? true : [*params[:tags]].compact
          end
          page_number = params[:page]&.to_i || 1
          # Make page size smaller for data intensive query
          page_size = params[:pageSize]&.to_i || (tags == true ? 30 : 100)
          options = {
            tags: tags,
            page_number: page_number,
            page_size: page_size
          }

          # TODO remove this code when verified
          options[:optimised] = true unless params[:optimised] == 'false'
          index_items = ViewDomain::IndexItems.new(index_service.find_index_items(options))

          page = tags ? :'index/show-with-tags' : :'index/show'
          locals = {
            title: "Pacts",
            index_items: index_items,
            page_number: page_number,
            page_size: page_size,
            pagination_record_count: index_items.pagination_record_count,
            current_page_size: index_items.size
          }

          haml page, {locals: locals, layout: :'layouts/main'}
        end

        def set_headers
          response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
          response.headers["Pragma"] = "no-cache"
          response.headers["Expires"] = "0"
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pact_broker-2.54.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.53.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.52.2 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.52.1 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.52.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.51.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.50.1 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.50.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.49.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.48.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.47.1 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.47.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.46.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.45.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.44.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.43.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.42.0 lib/pact_broker/ui/controllers/index.rb
pact_broker-2.41.0 lib/pact_broker/ui/controllers/index.rb