-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #395 from openstax/improve-performance
Improving application performance
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rufus-scheduler' | ||
scheduler = Rufus::Scheduler.new | ||
|
||
def populate_badges | ||
puts 'Starting the badge schedule' | ||
badges = OpenBadgeApi.instance.fetch_badges | ||
badge_ids = badges.map { |badge| badge['id'] } | ||
badge_ids.each do |id| | ||
OpenBadgeApi.instance.badge_info(id) | ||
end | ||
puts 'Fetched badges for the day' | ||
end | ||
|
||
# Run the job immediately | ||
scheduler.in '30s' do | ||
populate_badges | ||
end | ||
|
||
# Then schedule it to run every 24 hours | ||
scheduler.every '24h' do | ||
populate_badges | ||
end |