Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace parse-cron with fugit #710

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/models/foreman_tasks/recurring_logic.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ForemanTasks
require 'parse-cron'
require 'fugit'

class RecurringLogic < ApplicationRecord
include Authorizable
Expand Down Expand Up @@ -96,11 +96,11 @@ def cancel
end

def next_occurrence_time(time = Time.zone.now)
@parser ||= CronParser.new(cron_line, Time.zone)
@parser ||= Fugit.parse_cron(cron_line)
# @parser.next(start_time) is not inclusive of the start_time hence stepping back one run to include checking start_time for the first run.
before_next = @parser.next(@parser.last(time.in_time_zone))
return before_next if before_next >= time && tasks.count == 0
@parser.next(time)
before_next = @parser.next_time(@parser.previous_time(time.iso8601))
return before_next.utc.localtime if before_next >= time && tasks.count == 0
@parser.next_time(time).utc.localtime
end

def generate_delay_options(time = Time.zone.now, options = {})
Expand Down
2 changes: 1 addition & 1 deletion foreman-tasks.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ same resource. It also optionally provides Dynflow infrastructure for using it f
s.extra_rdoc_files = Dir['README*', 'LICENSE']

s.add_dependency "dynflow", '>= 1.6.0'
s.add_dependency 'fugit', '~> 1.8'
s.add_dependency "get_process_mem" # for memory polling
s.add_dependency "parse-cron", '~> 0.1.4'
s.add_dependency "sinatra" # for Dynflow web console

s.add_development_dependency 'factory_bot_rails', '~> 4.8.0'
Expand Down