schedule_triggered?

in lib/core/scheduler.rb [151:194]


    def schedule_triggered?(scheduling_settings, identifier, time_at_poll_start = Time.now)
      
      unless scheduling_settings.present? && scheduling_settings[:enabled] == true
        Utility::Logger.debug("#{identifier.capitalize} scheduling is disabled.")
        return false
      end

      current_schedule = scheduling_settings[:interval]

      
      if current_schedule.nil? || current_schedule.empty?
        Utility::Logger.warn("No sync schedule configured for #{identifier}.")
        return false
      end

      current_schedule =
        begin
          Utility::Cron.quartz_to_crontab(current_schedule)
        rescue StandardError => e
          Utility::ExceptionTracking.log_exception(e, "Unable to convert quartz (#{current_schedule}) to crontab.")
          return false
        end
      cron_parser = Fugit::Cron.parse(current_schedule)

      
      unless cron_parser
        Utility::Logger.error("Unable to parse sync schedule for #{identifier}: expression #{current_schedule} is not a valid Quartz Cron definition.")
        return false
      end

      next_trigger_time = cron_parser.next_time(time_at_poll_start)
      
      poll_window = time_at_poll_start + @poll_interval
      if next_trigger_time <= poll_window
        Utility::Logger.info("#{identifier.capitalize} sync is triggered by cron schedule #{current_schedule}.")
        return true
      else
        
        Utility::Logger.debug("Sync for #{identifier.capitalize} not triggered as #{next_trigger_time} occurs after the poll window #{poll_window}. Poll window began at #{time_at_poll_start}, poll interval is #{@poll_interval} seconds.")
      end

      false
    end