Skip to content

Commit

Permalink
[match] remove redundant fetching of profile devices and certificates (
Browse files Browse the repository at this point in the history
…#21409)

* [match] remove redundant fetching of profile devices and certificates

* chore: add device accessor to profile.rb
  • Loading branch information
nekrich committed Oct 31, 2023
1 parent bf9b200 commit 34a1635
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions match/lib/match/runner.rb
Expand Up @@ -337,7 +337,7 @@ def device_count_different?(profile: nil, keychain_path: nil, platform: nil, inc
portal_profile = all_profiles.detect { |i| i.uuid == uuid }

if portal_profile
profile_device_count = portal_profile.fetch_all_devices.count
profile_device_count = portal_profile.devices.count

device_classes =
case platform
Expand Down Expand Up @@ -418,7 +418,7 @@ def certificate_count_different?(profile: nil, keychain_path: nil, platform: nil
# * For portal certificates, we filter out the expired one but includes a new certificate;
# * Profile still contains an expired certificate and is valid.
# Thus, we need to check the validity of profile certificates too.
profile_certs_count = portal_profile.fetch_all_certificates.select(&:valid?).count
profile_certs_count = portal_profile.certificates.select(&:valid?).count

certificate_types =
case platform
Expand Down
2 changes: 1 addition & 1 deletion match/spec/runner_spec.rb
Expand Up @@ -292,7 +292,7 @@

before do
allow(profile).to receive(:uuid).and_return(uuid)
allow(profile).to receive(:fetch_all_devices).and_return([profile_device])
allow(profile).to receive(:devices).and_return([profile_device])
end

it "device is enabled" do
Expand Down
1 change: 1 addition & 0 deletions spaceship/lib/spaceship/connect_api/models/profile.rb
Expand Up @@ -15,6 +15,7 @@ class Profile

attr_accessor :bundle_id
attr_accessor :certificates
attr_accessor :devices

attr_mapping({
"name" => "name",
Expand Down

0 comments on commit 34a1635

Please sign in to comment.