Skip to content

Commit

Permalink
Merge pull request #15537 from eduardoj/fix/package_links
Browse files Browse the repository at this point in the history
Prevent N+1 query in project page
  • Loading branch information
danidoni committed Feb 1, 2024
2 parents 10295df + b72954e commit 19f7ea8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/app/datatables/package_datatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_raw_records
# rubocop:enable Naming/AccessorMethodName

def data
records.map do |record|
records.eager_load(:package_kinds).select("packages.*, bit_or(kind = 'link') AS kind_link").group('packages.id').map do |record|
{
name: name_with_link(record),
changed: format('%{duration} ago',
Expand All @@ -39,7 +39,7 @@ def data
def name_with_link(record)
name = []
name << link_to(record.name, package_show_path(package: record, project: @project))
name << tag.span('Link', class: 'badge text-bg-info') if record.is_link?
name << tag.span('Link', class: 'badge text-bg-info') if record.kind_link == 1
safe_join(name, ' ')
end
end

0 comments on commit 19f7ea8

Please sign in to comment.