Sha256: 6a60ce4f9b745b006b818a80cb21e4f6b0ef79e0c88dcff392dfff72bb57b1f2
Contents?: true
Size: 1.19 KB
Versions: 13
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true module Heya module Campaigns module Queries # {Queries::MembershipsToProcess} returns the CampaignMembership records # which should be processed by the scheduler. MembershipsToProcess = ->(user: nil) { Heya::CampaignMembership.to_process(user: user) } # Given a campaign and a user, {Queries::MembershipsForUpdate} # returns the user's campaign memberships which should be updated # concurrently. MembershipsForUpdate = ->(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 } # Given a campaign, {Queries::OrphanedMemberships} returns the campaign # memberships which are on steps have been removed from the campaign. OrphanedMemberships = ->(campaign) { CampaignMembership .where(campaign_gid: campaign.gid) .where.not(step_gid: campaign.steps.map(&:gid)) } end end end
Version data entries
13 entries across 13 versions & 1 rubygems