I'm doing a weather API which will get, process and save data from another API. In order to get the daily updates (request URL info, get the JSON/XML data, construct my data and save it to my database) I think the most proper way is to use an ActiveJob.
I want to schedule the job to run periodically. I would like something like UNIX cron or Spring @Scheduled annotation for Java.
I have seen another questions on Stack Overflow(this one) about scheduling jobs but they use external gems like whenever. I have been looking for a backend that allows to execute the job in the Rails API (Backends), but it seems that none of the available allows scheduling a job.
Is there anything on the Rails framework (version 5) that allows me to do what I'm trying to? Or I must use an external gem?
Thank you so much.
Edit If is useful for anyone, here is the schema for the job:
class ImportDailyDataJob < ApplicationJob
queue_as :default
def perform(*args)
# Do something later
end
private
def prepare_request
# return the request object
end
def request_data
# Get the data from external API.
end
def process_data
# Process the data
end
def save_processed_data
# Saves the data to the database
end
end