Skip to content

Commit

Permalink
Merge pull request #2398 from cloudnativedaysjp/fix-get-metrics-n1
Browse files Browse the repository at this point in the history
GET /metrics の n+1 を解消
  • Loading branch information
ne-sachirou authored Sep 18, 2024
2 parents c858497 + 93cbcd0 commit 4d2c162
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/middlewares/dreamkast_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d2c162

Please sign in to comment.