-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimise the query to load the tags with latest flags
- Loading branch information
Showing
4 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'pact_broker/domain/tag' | ||
|
||
module PactBroker | ||
module Domain | ||
describe Tag do | ||
before do | ||
td.create_consumer("foo") | ||
.create_consumer_version("1") | ||
.create_consumer_version_tag("dev") | ||
.create_consumer_version_tag("prod") | ||
.create_consumer_version("2") | ||
.create_consumer_version_tag("dev") | ||
.create_consumer_version_tag("bloop") | ||
.create_consumer_version("3") | ||
.create_consumer_version_tag("dev") | ||
.create_consumer("bar") | ||
.create_consumer_version("1") | ||
.create_consumer_version_tag("test") | ||
end | ||
|
||
it "returns the latest tags for the given pacticipant ids" do | ||
pacticipant = PactBroker::Domain::Pacticipant.order(:id).first | ||
tags = Tag.latest_tags_for_pacticipant_ids([pacticipant.id]).all | ||
expect(tags.collect(&:name).sort).to eq %w{bloop dev prod} | ||
expect(tags.find{ |t| t.name == "dev" }.version.number).to eq "3" | ||
expect(tags.find{ |t| t.name == "prod" }.version.number).to eq "1" | ||
expect(tags.find{ |t| t.name == "bloop" }.version.number).to eq "2" | ||
expect(tags.collect(&:version_id).compact.size).to eq 3 | ||
expect(tags.collect(&:created_at).compact.size).to eq 3 | ||
end | ||
end | ||
end | ||
end | ||
|
||
# Table: tags | ||
# Primary Key: (name, version_id) | ||
# Columns: | ||
# name | text | | ||
# version_id | integer | | ||
# created_at | timestamp without time zone | NOT NULL | ||
# updated_at | timestamp without time zone | NOT NULL | ||
# Indexes: | ||
# tags_pk | PRIMARY KEY btree (version_id, name) | ||
# ndx_tag_name | btree (name) | ||
# Foreign key constraints: | ||
# tags_version_id_fkey | (version_id) REFERENCES versions(id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters