From 3b871c0dcba59129e0604efcf73f92cfa7b884e1 Mon Sep 17 00:00:00 2001 From: 3v0k4 Date: Tue, 18 Jul 2023 13:39:55 +0200 Subject: [PATCH] perf(queue): send authors only on first request --- lib/knapsack_pro/client/api/v1/queues.rb | 6 +++--- .../knapsack_pro/client/api/v1/queues_spec.rb | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/knapsack_pro/client/api/v1/queues.rb b/lib/knapsack_pro/client/api/v1/queues.rb index cb46a2f8..5b4ae44b 100644 --- a/lib/knapsack_pro/client/api/v1/queues.rb +++ b/lib/knapsack_pro/client/api/v1/queues.rb @@ -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 diff --git a/spec/knapsack_pro/client/api/v1/queues_spec.rb b/spec/knapsack_pro/client/api/v1/queues_spec.rb index ace5a322..a71deea4 100644 --- a/spec/knapsack_pro/client/api/v1/queues_spec.rb +++ b/spec/knapsack_pro/client/api/v1/queues_spec.rb @@ -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 @@ -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