Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imadbourouche committed Mar 4, 2025
1 parent 2bd3c1f commit d5c238d
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def bring(*attributes)
next unless mapping
model = mapping[:model]
mapped_attr = mapping[:attribute]
hash[model][mapped_attr] = attr
hash[model][attr] = mapped_attr
end

fetch_from_ontology(grouped_attributes[:ontology]) if grouped_attributes[:ontology].any?
Expand All @@ -22,8 +22,8 @@ def bring(*attributes)

def fetch_from_ontology(attributes)
return if attributes.empty?
@ontology.bring(*attributes.keys)
attributes.each do |mapped_attr, attr|
@ontology.bring(*attributes.values)
attributes.each do |attr, mapped_attr|
self.send("#{attr}=", @ontology.send(mapped_attr)) if @ontology.respond_to?(mapped_attr)
end
end
Expand All @@ -32,8 +32,8 @@ def fetch_from_submission(attributes)
return if attributes.empty?
@latest ||= defined?(@ontology) ? @ontology.latest_submission(status: :ready) : @submission
return unless @latest
@latest.bring(*attributes.keys)
attributes.each do |mapped_attr, attr|
@latest.bring(*attributes.values)
attributes.each do |attr, mapped_attr|
self.send("#{attr}=", @latest.send(mapped_attr)) if @latest.respond_to?(mapped_attr)
end
end
Expand All @@ -42,8 +42,8 @@ def fetch_from_metrics(attributes)
return if attributes.empty?
@latest ||= defined?(@ontology) ? @ontology.latest_submission(status: :ready) : @submission
return unless @latest
@latest.bring(metrics: [attributes.keys])
attributes.each do |mapped_attr, attr|
@latest.bring(metrics: [attributes.values])
attributes.each do |attr, mapped_attr|
metric_value = @latest.metrics&.respond_to?(mapped_attr) ? @latest.metrics.send(mapped_attr) || 0 : 0
self.send("#{attr}=", metric_value)
end
Expand Down

0 comments on commit d5c238d

Please sign in to comment.