From 93cbcd0439ecc981d8f0f6d9e141787f24b0c76c Mon Sep 17 00:00:00 2001 From: ne-sachirou Date: Wed, 18 Sep 2024 20:20:29 +0900 Subject: [PATCH] =?UTF-8?q?GET=20/metrics=20=E3=81=AE=20n+1=20=E3=82=92?= =?UTF-8?q?=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/middlewares/dreamkast_exporter.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/middlewares/dreamkast_exporter.rb b/app/middlewares/dreamkast_exporter.rb index 6c502b212..b6ba100c9 100644 --- a/app/middlewares/dreamkast_exporter.rb +++ b/app/middlewares/dreamkast_exporter.rb @@ -85,18 +85,20 @@ def dreamkast_chat_count(metrics) end def dreamkast_registrants_count(metrics) + profile_counts = Profile.group(:conference_id).count Conference.all.each do |conf| metrics.set( - conf.profiles.count, + profile_counts[conf.id] || 0, labels: { conference_id: conf.id } ) end end def dreamkast_talks_count(metrics) + talk_counts = Talk.group(:conference_id).count Conference.all.each do |talks_count| metrics.set( - talks_count.talks.count, + talk_counts[talks_count.id] || 0, labels: { conference_id: talks_count.id } ) end