Skip to content

Instantly share code, notes, and snippets.

@Netznarkose
Last active November 1, 2019 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Netznarkose/e8e73f3adc0646b2c33c4ca6c1d9222b to your computer and use it in GitHub Desktop.
Save Netznarkose/e8e73f3adc0646b2c33c4ca6c1d9222b to your computer and use it in GitHub Desktop.

ticket https://brandslisten.atlassian.net/browse/BLCR-3399

params:

# participants_total 
# returns count of all confirmed or auto-confirmed participants
    has_many :participants, -> { distinct.joins(:participation_requests).where(bl_participation_requests: { status: %w[confirmed auto_confirmed] }) }, through: :participation_requests, source: :user

# participation_requests_total
# count of all confirmed, auto-confirmed, pending & decined participation requests
load_participation_requests.size

        def load_participation_requests
          @load_participation_requests ||= object.participation_requests.where(
            status: [
              :confirmed,
              :auto_confirmed,
              :pending,
              :declined
            ]
          ).preload(
            :user,
            :attachments,
            user: :profile_pictures
          )
        end

on current wl-sg
api returns:

"participation_requests_total": 8,
"participants_total": 6,

in backend:
6 confirmed members
2 pending members

frontend shows 6 + 2

on current eon-sg
api returns:
"participation_requests_total": ???, # not checked yet but probably 7
"participants_total": ???, # not checked yet but probably 5

in backend:
5 confirmed members
2 pending members

frontend shows 5 + 2

so my question is:
is it possible that participation_requests_total gets set somewhere in the frontend instead of participants_total? this would explain the inclusion of pending members in the testers-count

@BentBr
Copy link

BentBr commented Nov 1, 2019

Hey!
Why is for participation_requests the status relevant?
Should query all independent of status, only dependent of this one PT, not?

@Netznarkose
Copy link
Author

load_participation_requests is a private method, which fetches the appropriate participation requests to calculate theparticipation_requests_total.
new and invited are also valid status(i), these must be excluded beforehand, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment