Display counts for Added and Popped columns

This commit is contained in:
Jason Zimdars
2025-02-10 12:08:09 -06:00
parent 8b17a33a75
commit d5b13a8030
2 changed files with 15 additions and 4 deletions
+14 -3
View File
@@ -43,9 +43,20 @@ module EventsHelper
end.flatten)
end
def render_column_headers
[ "Touched", "Discussed", "Added", "Popped" ].map do |header|
content_tag(:h3, header, class: "event__grid-column-title margin-block-end-half position-sticky")
def render_column_headers(day = Date.current)
start_time = day.beginning_of_day
end_time = day.end_of_day
headers = {
"Touched" => nil,
"Discussed" => nil,
"Added" => Event.where(action: "published", created_at: start_time..end_time).count,
"Popped" => Event.where(action: "popped", created_at: start_time..end_time).count
}
headers.map do |header, count|
title = count&.positive? ? "#{header} (#{count})" : header
content_tag(:h3, title, class: "event__grid-column-title margin-block-end-half position-sticky")
end.join.html_safe
end
+1 -1
View File
@@ -4,7 +4,7 @@
<h2 class="txt-large margin-block-end-half"><%= event_day_title(activity_day) %></h2>
<div class="center events">
<%= render_column_headers %>
<%= render_column_headers(activity_day) %>
<%= render_event_grid_cells(activity_day) %>
<% events.each do | hour_column, cluster| %>