Skip to content

Commit

Permalink
refactoring few raw_first_column/raw_row in templates with pluck and …
Browse files Browse the repository at this point in the history
…ids aces#1454
  • Loading branch information
MontrealSergiy committed Jan 14, 2025
1 parent aec2730 commit c618437
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion BrainPortal/app/views/tasks/_tasks_display.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
<%= colored_archived_status(as) %>
<% if task.cluster_workdir_size.present? %>
<%= colored_pretty_size(task.cluster_workdir_size, :blank => '') %>
<% elsif as == :userfile && ar_file_size = Userfile.where(:id => task.workdir_archive_userfile_id).raw_first_column(:size)[0] %>
<% elsif as == :userfile && ar_file_size = Userfile.where(:id => task.workdir_archive_userfile_id).pluck(:size)[0] %>
(<%= colored_pretty_size(ar_file_size, :blank => '') %>)
<% end %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
Full list of tags:<br>
<select name="tag_ids[]" multiple="multiple" style="width: 15em" size="4" >
<%= options_from_collection_for_select current_user.available_tags, 'id', 'name',
@userfile.get_tags_for_user(current_user).raw_first_column(:id) %>
@userfile.get_tags_for_user(current_user).ids %>
</select>
</fieldset>

Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/app/views/users/_users_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
) { |u| u.last_connected_at ? to_localtime(u.last_connected_at, :datetime) : "Unknown" }

t.column("Projects", :groups) do |u|
group_names = u.assignable_groups.order(:name).raw_first_column(:name).reject { |n| n == u.login }
group_names = u.assignable_groups.order(:name).pluck(:name).reject { |n| n == u.login }
if group_names.size > 1 && group_names.size < 40
html_tool_tip(pluralize(group_names.size, "project"), :offset_x => 60) do
array_to_table(group_names,
Expand Down
6 changes: 2 additions & 4 deletions BrainPortal/lib/tasks/cbrain_plugins.rake
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ namespace :cbrain do
puts "Checking for orphan userfiles..."
orphan_userfiles = Userfile
.where("type not in (?)", userfile_classes)
.raw_rows([:id, :type])
.to_a
.pluck(:id, :type)
unless orphan_userfiles.empty?
puts "#{orphan_userfiles.size} orphan userfile(s) found:"
orphan_userfiles.each do |orphan|
Expand All @@ -423,8 +422,7 @@ namespace :cbrain do
puts "Checking for orphan tasks..."
orphan_tasks = CbrainTask
.where("type not in (?)", task_classes)
.raw_rows([:id, :type])
.to_a
.pluck(:id, :type)
unless orphan_tasks.empty?
puts "#{orphan_tasks.size} orphan task(s) found:"
orphan_tasks.each do |orphan|
Expand Down

0 comments on commit c618437

Please sign in to comment.