Skip to content

Commit

Permalink
fix(api): Missing VM tags in API
Browse files Browse the repository at this point in the history
  • Loading branch information
mromulus committed Feb 16, 2024
1 parent dda48ea commit 6510f09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 1 addition & 10 deletions app/calculation/generate_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,9 @@ def network_result

def virtual_machine_result
[].tap do |results|
if subject.numbered_actor && !subject.numbered_actor.subtree.include?(subject.actor)
results << {
id: ActorAPIName.result_for(subject.actor, numbered_by: subject.numbered_actor),
name: ActorAPIName.result_for(subject.actor, numbered_by: subject.numbered_actor),
config_map: {},
children: []
}
end

if subject.customization_specs.size > 1
results << {
id: "#{subject.name}_all_specs",
id: "#{subject.name.tr('-', '_')}_all_specs",
name: "All specs for #{subject.name}",
config_map: {},
children: [],
Expand Down
8 changes: 7 additions & 1 deletion app/presenters/api/v3/tags_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module API
module V3
class TagsPresenter < Struct.new(:exercise, :scope)
def as_json(_opts)
actor_tags + os_tags + zone_tags + capability_tags + spec_tags
actor_tags + vm_tags + os_tags + zone_tags + capability_tags + spec_tags
end

private
Expand Down Expand Up @@ -55,6 +55,12 @@ def spec_tags
GenerateTags.result_for(spec_scope.all).uniq
end
end

def vm_tags
Rails.cache.fetch(['apiv3', exercise.cache_key_with_version, 'vm_tags', vm_scope.cache_key_with_version]) do
GenerateTags.result_for(vm_scope.all).uniq
end
end
end
end
end

0 comments on commit 6510f09

Please sign in to comment.