Module: Heya::Campaigns::Queries
- Defined in:
- lib/heya/campaigns/queries.rb
Constant Summary collapse
- MembershipsToProcess =
MembershipsToProcess returns the CampaignMembership records which should be processed by the scheduler.
->(user: nil) { Heya::CampaignMembership.to_process(user: user) }
- MembershipsForUpdate =
Given a campaign and a user, MembershipsForUpdate returns the user’s campaign memberships which should be updated concurrently.
->(campaign, user) { membership = CampaignMembership.where(user: user, campaign_gid: campaign.gid).first if membership.concurrent? CampaignMembership .where(user: user, campaign_gid: campaign.gid) else CampaignMembership .where(user: user, concurrent: false) end }
- OrphanedMemberships =
Given a campaign, OrphanedMemberships returns the campaign memberships which are on steps have been removed from the campaign.
->(campaign) { CampaignMembership .where(campaign_gid: campaign.gid) .where.not(step_gid: campaign.steps.map(&:gid)) }