diff --git a/js/src/components/Event/EventListCard.vue b/js/src/components/Event/EventListCard.vue index df9558abe..dee178ee7 100644 --- a/js/src/components/Event/EventListCard.vue +++ b/js/src/components/Event/EventListCard.vue @@ -63,11 +63,11 @@ $tc( "{available}/{capacity} available places", participation.event.options.maximumAttendeeCapacity - - (participation.event.participantStats.going - 1), + participation.event.participantStats.participant, { available: participation.event.options.maximumAttendeeCapacity - - (participation.event.participantStats.going - 1), + participation.event.participantStats.participant, capacity: participation.event.options.maximumAttendeeCapacity, } ) diff --git a/js/src/views/Event/Event.vue b/js/src/views/Event/Event.vue index e0e9c9dfe..56b1e9698 100644 --- a/js/src/views/Event/Event.vue +++ b/js/src/views/Event/Event.vue @@ -174,11 +174,11 @@ $tc( "{available}/{capacity} available places", event.options.maximumAttendeeCapacity - - (event.participantStats.going - 1), + event.participantStats.participant, { available: event.options.maximumAttendeeCapacity - - (event.participantStats.going - 1), + event.participantStats.participant, capacity: event.options.maximumAttendeeCapacity, } ) @@ -186,8 +186,8 @@ {{ - $tc("No one is going to this event", event.participantStats.going - 1, { - going: event.participantStats.going - 1, + $tc("No one is going to this event", event.participantStats.participant, { + going: event.participantStats.participant, }) }} @@ -197,10 +197,12 @@ {{ $tc( "{available}/{capacity} available places", - event.options.maximumAttendeeCapacity - event.participantStats.going, + event.options.maximumAttendeeCapacity - + event.participantStats.participant, { available: - event.options.maximumAttendeeCapacity - event.participantStats.going, + event.options.maximumAttendeeCapacity - + event.participantStats.participant, capacity: event.options.maximumAttendeeCapacity, } ) @@ -208,8 +210,8 @@ {{ - $tc("No one is going to this event", event.participantStats.going, { - going: event.participantStats.going, + $tc("No one is going to this event", event.participantStats.participant, { + going: event.participantStats.participant, }) }} diff --git a/lib/graphql/resolvers/event.ex b/lib/graphql/resolvers/event.ex index 808de4fd3..0bf80ee8c 100644 --- a/lib/graphql/resolvers/event.ex +++ b/lib/graphql/resolvers/event.ex @@ -107,24 +107,31 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do {:ok, %{total: 0, elements: []}} end - def stats_participants_going(%EventParticipantStats{} = stats, _args, _resolution) do - {:ok, stats.participant + stats.moderator + stats.administrator + stats.creator} - end - def stats_participants( %Event{participant_stats: %EventParticipantStats{} = stats, id: event_id} = _event, _args, %{context: %{current_user: %User{id: user_id} = _user}} = _resolution ) do - going = stats.participant + stats.moderator + stats.administrator + stats.creator - if Events.is_user_moderator_for_event?(user_id, event_id) do - {:ok, Map.put(stats, :going, going)} + {:ok, + Map.put( + stats, + :going, + stats.participant + stats.moderator + stats.administrator + stats.creator + )} else - {:ok, %{going: going}} + {:ok, %{participant: stats.participant}} end end + def stats_participants( + %Event{participant_stats: %EventParticipantStats{participant: participant}}, + _args, + _resolution + ) do + {:ok, %EventParticipantStats{participant: participant}} + end + def stats_participants(_event, _args, _resolution) do {:ok, %EventParticipantStats{}} end