Skip to content

Commit

Permalink
perf(queue): send authors only on first request
Browse files Browse the repository at this point in the history
  • Loading branch information
3v0k4 committed Jul 18, 2023
1 parent a1e7d4b commit 3b871c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/knapsack_pro/client/api/v1/queues.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def queue(args)
:node_index => args.fetch(:node_index),
:node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
:user_seat => KnapsackPro::Config::Env.masked_user_seat,
:build_author => KnapsackPro::RepositoryAdapters::GitAdapter.new.build_author,
:commit_authors => KnapsackPro::RepositoryAdapters::GitAdapter.new.commit_authors,
}

if request_hash[:can_initialize_queue] && !request_hash[:attempt_connect_to_queue]
request_hash.merge!({
:test_files => args.fetch(:test_files)
:test_files => args.fetch(:test_files),
:build_author => KnapsackPro::RepositoryAdapters::GitAdapter.new.build_author,
:commit_authors => KnapsackPro::RepositoryAdapters::GitAdapter.new.commit_authors,
})
end

Expand Down
20 changes: 10 additions & 10 deletions spec/knapsack_pro/client/api/v1/queues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@
).and_return(action)
expect(subject).to eq action
end

it "sends authors" do
action = double

expect(KnapsackPro::Client::API::Action).to receive(:new).with(
hash_including(request_hash: hash_including(:build_author, :commit_authors))
).and_return(action)

expect(subject).to eq action
end
end

context 'when can_initialize_queue=false and attempt_connect_to_queue=false' do
Expand All @@ -67,15 +77,5 @@
expect(subject).to eq action
end
end

it "sends authors" do
action = double

expect(KnapsackPro::Client::API::Action).to receive(:new).with(
hash_including(request_hash: hash_including(:build_author, :commit_authors))
).and_return(action)

expect(subject).to eq action
end
end
end

0 comments on commit 3b871c0

Please sign in to comment.