Created
May 26, 2021 20:13
-
-
Save parthaa/754d896decc68b91108a1e3f2a36dc14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def interested_hostgroups | |
Hostgroup.where(id: Katello::Hostgroup::ContentFacet.where(content_source_id: nil, kickstart_repository_id: nil, content_view_id: nil, lifecycle_environment_id: nil).select(:hostgroup_id)) | |
end | |
def pick_facet_values(hg) | |
facet_values = {} | |
hg.audits.reverse.each do |audit| | |
hg_changes = audit.audited_changes.slice("lifecycle_environment_id", "kickstart_repository_id", "content_view_id", "content_source_id") | |
facet_values = hg_changes.merge(facet_values) | |
end | |
facet_values.map do |k,v| | |
v = v[-1] if v.is_a? Array | |
[k, v] | |
end.to_h | |
end | |
interested_hostgroups.each do |hg| | |
hg.content_facet.update!(pick_facet_values(hg)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment