Skip to content

Commit eb6e867

Browse files
committed
Add method for getting event attendances
Apply the method across the events area, in the same way we did for workshops Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
1 parent 7b26aa2 commit eb6e867

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

app/controllers/events_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def index
2323
events << Event.upcoming.includes(:venue, :sponsors).all
2424
events = events.compact.flatten.sort_by(&:date_and_time).group_by(&:date)
2525
@events = events.map.inject({}) { |hash, (key, value)| hash[key] = EventPresenter.decorate_collection(value); hash }
26+
@attending_ids = MemberPresenter.new(current_user).attending_events
2627
end
2728

2829
def show

app/presenters/member_presenter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def attending_workshops
3232
@member.nil? ? Set.new : workshop_invitations.accepted.pluck(:id).to_set
3333
end
3434

35+
def attending_events
36+
@member.nil? ? Set.new : invitations.accepted.pluck(:id).to_set
37+
end
38+
3539
private
3640

3741
def coach_pairing_details(note)

app/views/events/_events.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
%h3.h5= date
55
.row
66
.col-md-8
7-
= render workshops
7+
= render workshops, attending_ids: attending_ids

app/views/events/index.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
.col
66
- if @events.any?
77
%h3.mb-4 Upcoming Events
8-
= render partial: 'events', locals: { grouped_events: @events }
8+
= render partial: 'events', locals: { grouped_events: @events, attending_ids: @attending_ids}
99

1010
.container{'data-test': 'past-events'}
1111
.row
1212
.col
1313
- if @past_events.any?
1414
%h3.mb-4 Past Events
15-
= render partial: 'events', locals: { grouped_events: @past_events }
15+
= render partial: 'events', locals: { grouped_events: @past_events, attending_ids: @attending_ids }

0 commit comments

Comments
 (0)