PERF: avoid checking card background and user background when not supplied (#11299)

Previously we were performing a bunch of needless work when SSO failed
to supply profile and card backgrounds.
This commit is contained in:
Sam 2020-11-25 10:53:44 +11:00 committed by GitHub
parent 51f9a56137
commit 3e1b94c227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,27 +305,32 @@ class DiscourseSingleSignOn < SingleSignOn
end end
end end
profile_background_missing = user.user_profile.profile_background_upload.blank? || Upload.get_from_url(user.user_profile.profile_background_upload.url).blank? if profile_background_url.present?
if (profile_background_missing || SiteSetting.sso_overrides_profile_background) && profile_background_url.present? profile_background_missing = user.user_profile.profile_background_upload.blank? || Upload.get_from_url(user.user_profile.profile_background_upload.url).blank?
profile_background_changed = sso_record.external_profile_background_url != profile_background_url
if profile_background_changed || profile_background_missing if profile_background_missing || SiteSetting.sso_overrides_profile_background
Jobs.enqueue(:download_profile_background_from_url, profile_background_changed = sso_record.external_profile_background_url != profile_background_url
url: profile_background_url, if profile_background_changed || profile_background_missing
user_id: user.id, Jobs.enqueue(:download_profile_background_from_url,
is_card_background: false url: profile_background_url,
) user_id: user.id,
is_card_background: false
)
end
end end
end end
card_background_missing = user.user_profile.card_background_upload.blank? || Upload.get_from_url(user.user_profile.card_background_upload.url).blank? if card_background_url.present?
if (card_background_missing || SiteSetting.sso_overrides_profile_background) && card_background_url.present? card_background_missing = user.user_profile.card_background_upload.blank? || Upload.get_from_url(user.user_profile.card_background_upload.url).blank?
card_background_changed = sso_record.external_card_background_url != card_background_url if card_background_missing || SiteSetting.sso_overrides_profile_background
if card_background_changed || card_background_missing card_background_changed = sso_record.external_card_background_url != card_background_url
Jobs.enqueue(:download_profile_background_from_url, if card_background_changed || card_background_missing
url: card_background_url, Jobs.enqueue(:download_profile_background_from_url,
user_id: user.id, url: card_background_url,
is_card_background: true user_id: user.id,
) is_card_background: true
)
end
end end
end end