app/models/maestrano/connector/rails/concerns/connec_helper.rb in maestrano-connector-rails-1.2.2 vs app/models/maestrano/connector/rails/concerns/connec_helper.rb in maestrano-connector-rails-1.2.3
- old
+ new
@@ -16,20 +16,20 @@
client.class.headers('CONNEC-EXTERNAL-IDS' => 'true')
client
end
def connec_version(organization)
- @@connec_version = Rails.cache.fetch('connec_version', namespace: 'maestrano', expires_in: 1.day) do
+ @@connec_version = Rails.cache.fetch("connec_version_#{organization.tenant}", namespace: 'maestrano', expires_in: 1.day) do
response = get_client(organization).class.get("#{Maestrano[organization.tenant].param('connec.host')}/version")
response = JSON.parse(response.body)
@@connec_version = response['ci_branch']
end
@@connec_version
end
# Replace the ids arrays by the external id
- # If a reference has no id for this oauth_provider and oauth_uid but has one for connec returns nil
+ # If a reference has no id for this oauth_provider and oauth_uid but has one for connec, returns nil
def unfold_references(connec_entity, references, organization)
unfolded_connec_entity = connec_entity.with_indifferent_access
not_nil = true
# Id
@@ -83,9 +83,10 @@
ref = array_of_refs.shift
field = entity[ref]
# Unfold the id
if array_of_refs.empty? && field
+ return entity.delete(ref) if field.is_a?(String) # ~retro-compatibility to ease transition aroud Connec! idmaps rework. Should be removed eventually.
id_hash = field.find { |id| id[:provider] == organization.oauth_provider && id[:realm] == organization.oauth_uid }
if id_hash
entity[ref] = id_hash['id']
elsif field.find { |id| id[:provider] == 'connec' } # Should always be true as ids will always contain a connec id
# We may enqueue a fetch on the endpoint of the missing association, followed by a re-fetch on this one.