Method: OpenC3::TargetModel.all_modified
- Defined in:
- lib/openc3/models/target_model.rb
.all_modified(scope:) ⇒ Object
All targets with indication of modified targets
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/openc3/models/target_model.rb', line 86 def self.all_modified(scope:) targets = self.all(scope: scope) targets.each { |target_name, target| target['modified'] = false } rubys3_client = Aws::S3::Client.new token = nil while true resp = rubys3_client.list_objects_v2({ bucket: 'config', max_keys: 1000, # The trailing slash is important! prefix: "#{scope}/targets_modified/", delimiter: '/', continuation_token: token }) resp.common_prefixes.each do |item| # Results look like DEFAULT/targets_modified/INST/ # so split on '/' and pull out the last value target_name = item.prefix.split('/')[-1] # A target could have been deleted without removing the modified files # Thus we have to check for the existance of the target_name key if targets.has_key?(target_name) targets[target_name]['modified'] = true end end break unless resp.is_truncated token = resp.next_continuation_token end # Sort (which turns hash to array) and return hash # This enables a consistent listing of the targets targets.sort.to_h end |