Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def faq; end
def about; end

def wall_of_fame
@coaches_count = top_coach_query.length
@coaches_count = WorkshopInvitation.to_coaches.attended.distinct.count(:member_id)
coaches = Member.where(id: top_coach_query
.year(year_param))
.includes(:skills)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class AddCoachAttendedIndexToWorkshopInvitations < ActiveRecord::Migration[8.1]
disable_ddl_transaction!

def up
add_index :workshop_invitations, :member_id,
where: "attended AND role = 'Coach'",
name: :index_workshop_invitations_coach_attended_on_member_id,
algorithm: :concurrently
end

def down
remove_index :workshop_invitations,
name: :index_workshop_invitations_coach_attended_on_member_id,
algorithm: :concurrently
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.1].define(version: 2026_09_17_023327) do
ActiveRecord::Schema[8.1].define(version: 2026_09_17_090000) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"

Expand Down Expand Up @@ -615,6 +615,7 @@
t.integer "workshop_id"
t.index ["member_id", "attending"], name: "index_workshop_invitations_member_attending"
t.index ["member_id", "workshop_id", "role"], name: "idx_on_member_id_workshop_id_role_e3cea6bbfd", unique: true
t.index ["member_id"], name: "index_workshop_invitations_coach_attended_on_member_id", where: "(attended AND ((role)::text = 'Coach'::text))"
t.index ["member_id"], name: "index_workshop_invitations_on_member_id"
t.index ["token"], name: "index_workshop_invitations_on_token", unique: true
t.index ["workshop_id", "attending"], name: "index_workshop_invitations_workshop_attending"
Expand Down
13 changes: 13 additions & 0 deletions spec/features/listing_coaches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
expect(page).to have_text(coach.name, wait: 5)
end

scenario 'I can see the total number of volunteers across all years' do
workshop_last_year = Fabricate(:workshop, date_and_time: 1.year.ago)
workshop_three_years_ago = Fabricate(:workshop, date_and_time: 3.years.ago)
coach = Fabricate(:attended_coach, workshop: workshop_last_year).member
Fabricate(:attended_coach, member: coach, workshop: workshop_three_years_ago)
Fabricate(:attended_coach, workshop: workshop_three_years_ago)

visit coaches_path

# The same coach at two workshops counts once
expect(page).to have_text('the 2 volunteers', wait: 5)
end

scenario 'I can see the top coaches by year' do
travel_to(Time.current) do
latest_workshop = Fabricate(:workshop, date_and_time: 1.year.ago)
Expand Down