Sha256: 3be9e5f6188ed1ec2f32d4eba8bd9c82c17deb144a1f3baa3cfac5c8fb46ee62
Contents?: true
Size: 1.71 KB
Versions: 6
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true namespace :decidim_initiatives do desc "Checks validating initiatives and moves all without changes for a configured time to discarded state" task check_validating: :environment do Decidim::Initiatives::OutdatedValidatingInitiatives .for(Decidim::Initiatives.max_time_in_validating_state) .each(&:discarded!) end desc "Checks published initiatives and moves to accepted/rejected state depending on the votes collected when the signing period has finished" task check_published: :environment do Decidim::Initiatives::SupportPeriodFinishedInitiatives.new.each do |initiative| if initiative.supports_goal_reached? initiative.accepted! else initiative.rejected! end end end desc "Notifies progress on published initiatives" task notify_progress: :environment do Decidim::Initiative .published .where.not(first_progress_notification_at: nil) .where(second_progress_notification_at: nil).find_each do |initiative| if initiative.percentage >= Decidim::Initiatives.second_notification_percentage notifier = Decidim::Initiatives::ProgressNotifier.new(initiative:) notifier.notify initiative.second_progress_notification_at = Time.now.utc initiative.save end end Decidim::Initiative .published .where(first_progress_notification_at: nil).find_each do |initiative| if initiative.percentage >= Decidim::Initiatives.first_notification_percentage notifier = Decidim::Initiatives::ProgressNotifier.new(initiative:) notifier.notify initiative.first_progress_notification_at = Time.now.utc initiative.save end end end end
Version data entries
6 entries across 6 versions & 1 rubygems