Sha256: f532a547e872734138e6973896c5e364250885457480b5f5ff5bfa77c1f39f7b

Contents?: true

Size: 1.43 KB

Versions: 26

Compression:

Stored size: 1.43 KB

Contents

require 'pact_broker/domain/tag'
require 'pact_broker/repositories/helpers'


module PactBroker
  module Tags
    class Repository

      include PactBroker::Repositories::Helpers

      def create args
        Domain::Tag.new(name: args.fetch(:name), version: args.fetch(:version)).save
      end

      def find args
        PactBroker::Domain::Tag
          .select_all_qualified
          .join(:versions, { id: :version_id })
          .join(:pacticipants, {Sequel.qualify("pacticipants", "id") => Sequel.qualify("versions", "pacticipant_id")})
          .where(name_like(Sequel.qualify("tags", "name"), args.fetch(:tag_name)))
          .where(name_like(Sequel.qualify("versions", "number"), args.fetch(:pacticipant_version_number)))
          .where(name_like(Sequel.qualify("pacticipants", "name"), args.fetch(:pacticipant_name)))
          .single_record
      end

      def delete_by_version_id version_id
        Sequel::Model.db[:tags].where(version_id: version_id).delete
      end

      def find_all_tag_names_for_pacticipant pacticipant_name
        PactBroker::Domain::Tag
        .select(Sequel[:tags][:name])
        .join(:versions, { Sequel[:versions][:id] => Sequel[:tags][:version_id] })
        .join(:pacticipants, { Sequel[:pacticipants][:id] => Sequel[:versions][:pacticipant_id] })
        .where(Sequel[:pacticipants][:name] => pacticipant_name)
        .distinct
        .collect{ |tag| tag[:name] }.sort
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
pact_broker-2.26.0 lib/pact_broker/tags/repository.rb
pact_broker-2.25.0 lib/pact_broker/tags/repository.rb
pact_broker-2.24.0 lib/pact_broker/tags/repository.rb
pact_broker-2.23.4 lib/pact_broker/tags/repository.rb
pact_broker-2.23.3 lib/pact_broker/tags/repository.rb
pact_broker-2.23.2 lib/pact_broker/tags/repository.rb
pact_broker-2.23.1 lib/pact_broker/tags/repository.rb
pact_broker-2.23.0 lib/pact_broker/tags/repository.rb
pact_broker-2.22.0 lib/pact_broker/tags/repository.rb
pact_broker-2.21.0 lib/pact_broker/tags/repository.rb
pact_broker-2.20.0 lib/pact_broker/tags/repository.rb
pact_broker-2.19.2 lib/pact_broker/tags/repository.rb
pact_broker-2.19.1 lib/pact_broker/tags/repository.rb
pact_broker-2.19.0 lib/pact_broker/tags/repository.rb
pact_broker-2.18.0 lib/pact_broker/tags/repository.rb
pact_broker-2.17.1 lib/pact_broker/tags/repository.rb
pact_broker-2.17.0 lib/pact_broker/tags/repository.rb
pact_broker-2.16.1 lib/pact_broker/tags/repository.rb
pact_broker-2.16.0 lib/pact_broker/tags/repository.rb
pact_broker-2.15.0 lib/pact_broker/tags/repository.rb