Skip to content

Commit

Permalink
rubocop map logic
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Apr 8, 2024
1 parent 7840911 commit df48fba
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 86 deletions.
6 changes: 1 addition & 5 deletions src-colladmin/actions/ingest_batch_folders_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,14 @@ def empty?
end

def to_table
table = []
bfs = @batch_folders.sort do |a, b|
if a.status == b.status
b.dtime <=> a.dtime
else
AdminTask.status_sort_val(a.status) <=> AdminTask.status_sort_val(b.status)
end
end
bfs.each do |bf|
table.append(bf.table_row)
end
table
bfs.map(&:table_row)
end

def apply_queue_list(queue_list)
Expand Down
6 changes: 2 additions & 4 deletions src-colladmin/actions/ingest_job_manifest_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ def initialize(json)
end

def self.table_headers
arr = []
JobManifestEntry.placeholder.get_property_list.each do |sym|
arr.append(JobManifestEntry.placeholder.get_label(sym))
JobManifestEntry.placeholder.get_property_list.map do |sym|
JobManifestEntry.placeholder.get_label(sym)
end
arr
end

def self.table_types
Expand Down
6 changes: 1 addition & 5 deletions src-colladmin/actions/ingest_job_metadata_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ def initialize(body)
end

def to_table
rows = []
@metadata.each do |jmr|
rows.append(jmr.to_table_row)
end
rows
@metadata.map(&:to_table_row)
end
end
6 changes: 2 additions & 4 deletions src-colladmin/actions/opensearch_describe_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def process_key(k, defstat)
end

def table_rows(_body)
rows = []
oskeys = {}

@fields.each_key do |k|
Expand All @@ -82,10 +81,9 @@ def table_rows(_body)

oskeys[k] = process_key(k, 'WARN')
end
oskeys.keys.sort.each do |k|
rows.append(oskeys[k])
oskeys.keys.sort.map do |k|
oskeys[k]
end
rows
end

def has_table
Expand Down
5 changes: 2 additions & 3 deletions src-colladmin/actions/replication_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ def maintidlist_params(status)
end

def maintidlist_placeholders
placeholders = []
@myparams.fetch('maintidlist', '').split(',').each do |_id|
placeholders.append('?')
placeholders = @myparams.fetch('maintidlist', '').split(',').map do |_id|
'?'
end
placeholders.join(',')
end
Expand Down
6 changes: 2 additions & 4 deletions src-colladmin/actions/tag_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ def perform_action
end

def get_table_rows
rows = []
@instances.keys.sort.each do |k|
rows.append(@instances[k].table_row(self))
@instances.keys.sort.map do |k|
@instances[k].table_row(self)
end
rows
end

def has_table
Expand Down
6 changes: 2 additions & 4 deletions src-colladmin/actions/tag_uc3_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ def perform_action
end

def get_table_rows
rows = []
@instances.keys.sort.each do |k|
rows.append(@instances[k].table_row(self))
@instances.keys.sort.map do |k|
@instances[k].table_row(self)
end
rows
end

def has_table
Expand Down
6 changes: 2 additions & 4 deletions src-colladmin/lambda_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,9 @@ def get_actions_map
actmap[path] = [] unless actmap.key?(path)
actmap[path].push(act)
end
maplist = []
actmap.keys.sort.each do |p|
maplist.push({ path: p, actions: actmap[p] })
actmap.keys.sort.map do |p|
{ path: p, actions: actmap[p] }
end
maplist
end
end
end
6 changes: 2 additions & 4 deletions src-colladmin/lib/acc_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ def initialize(json)
end

def self.table_headers
arr = []
AccQueueEntry.placeholder.get_property_list.each do |sym|
arr.append(AccQueueEntry.placeholder.get_label(sym))
AccQueueEntry.placeholder.get_property_list.map do |sym|
AccQueueEntry.placeholder.get_label(sym)
end
arr
end

def self.table_types
Expand Down
8 changes: 1 addition & 7 deletions src-colladmin/lib/admin_objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,7 @@ def self.table_types
end

def table_rows
rows = []
@profiles.each do |p|
rows.push(
p.to_table_row
)
end
rows
@profiles.map(&:to_table_row)
end

attr_reader :profiles
Expand Down
6 changes: 2 additions & 4 deletions src-colladmin/lib/inv_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ def initialize(json)
end

def self.table_headers
arr = []
InvQueueEntry.placeholder.get_property_list.each do |sym|
arr.append(InvQueueEntry.placeholder.get_label(sym))
InvQueueEntry.placeholder.get_property_list.map do |sym|
InvQueueEntry.placeholder.get_label(sym)
end
arr
end

def self.table_types
Expand Down
6 changes: 2 additions & 4 deletions src-colladmin/lib/lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ def initialize(json)
end

def self.table_headers
arr = []
LockEntry.placeholder.get_property_list.each do |sym|
arr.append(LockEntry.placeholder.get_label(sym))
LockEntry.placeholder.get_property_list.map do |sym|
LockEntry.placeholder.get_label(sym)
end
arr
end

def self.table_types
Expand Down
28 changes: 9 additions & 19 deletions src-colladmin/lib/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,20 @@ def initialize(body, collections)
end

def table_rows
rows = []
@profiles.each do |p|
# next if p.is_template?
rows.append(p.summary_values)
end
rows
@profiles.map(&:summary_values)
end

def notification_map
map = {}
@profiles.each do |p|
map[p.get_value(:context)] = p.get_value(:contactsEmail).join(',')
end
omap = []
map.keys.sort.each do |k|
omap.push({
map.keys.sort.map do |k|
{
mnemonic: k,
contacts: map[k]
})
}
end
omap
end

def recent_profiles
Expand All @@ -60,14 +53,12 @@ def recent_profiles
context: p.get_value(:context)
}
end
omap = []
map.keys.sort.reverse.each do |k|
omap.push({
map.keys.sort.reverse.map do |k|
{
ark: map[k][:ark],
name: "#{map[k][:context]}: #{map[k][:name]}"
})
}
end
omap
end

attr_reader :profiles
Expand Down Expand Up @@ -330,9 +321,8 @@ def summary_types
end

def summary_headers
arr = []
summary_symbols.each do |sym|
arr.append(get_label(sym))
arr = summary_symbols.map do |sym|
get_label(sym)
end
arr.append('Score')
arr.append('Collection')
Expand Down
6 changes: 2 additions & 4 deletions src-colladmin/lib/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ def check_filter(filter)
end

def self.table_headers
arr = []
QueueEntry.placeholder.get_property_list.each do |sym|
arr.append(QueueEntry.placeholder.get_label(sym))
QueueEntry.placeholder.get_property_list.map do |sym|
QueueEntry.placeholder.get_label(sym)
end
arr
end

def self.table_types
Expand Down
18 changes: 7 additions & 11 deletions src-colladmin/lib/storage_nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -841,18 +841,16 @@ def owner_clause
end

def search
objects = []
params = []
@norm_search.each do |p|
params.append(p)
params = @norm_search.map do |p|
p
end
params.push(@owner) unless @owner.empty?

run_query(
get_sql,
params
).each do |r|
objects.push({
).map do |r|
{
coll: r[0],
owner: r[1],
id: r[2],
Expand All @@ -867,17 +865,15 @@ def search
file_count_fmt: MerrittQuery.num_format(r[10]),
billable_size: r[11].nil? ? 0 : r[11],
billable_size_fmt: MerrittQuery.num_format(r[11].nil? ? 0 : r[11])
})
}
end
objects
end

attr_reader :objects

def get_placeholders
p = []
@norm_search.each do |_s|
p.append('?')
p = @norm_search.map do |_s|
'?'
end
p.join(',')
end
Expand Down

0 comments on commit df48fba

Please sign in to comment.