Commit 896687d4 authored by Sean Arnold's avatar Sean Arnold

Update and reduce queries

parent 473b8e7e
......@@ -145,8 +145,8 @@ module AlertManagement
end
def self.last_prometheus_alert_by_project_id
ids = select(arel_table[:id].maximum.as('id')).group(:project_id).map(&:id)
with_prometheus_alert.find(ids)
ids = select(arel_table[:id].maximum).group(:project_id)
with_prometheus_alert.where(id: ids)
end
def details
......
......@@ -41,7 +41,7 @@ RSpec.describe Dashboard::Operations::ListService do
it 'ensures a fixed amount of queries' do
queries = ActiveRecord::QueryRecorder.new { subject }.count
expect(queries).to eq(8)
expect(queries).to eq(7)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment