Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.
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
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ Style/RescueStandardError:
- 'app/lib/json_web_token.rb'
- 'app/lib/send_grid_client.rb'
- 'config/initializers/core_extensions/devise/strategies/json_web_token.rb'
- 'lib/tasks/git_hub.rake'
- 'lib/tasks/meetup.rake'
- 'lib/tasks/resource.rake'
- 'lib/tasks/users.rake'
Expand Down
2 changes: 1 addition & 1 deletion .ruby-gemset
Original file line number Diff line number Diff line change
@@ -1 +1 @@
operationcode_backend
-global
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ gem 'rubocop', '~> 0.55.0', require: false
gem 'sendgrid-ruby'
gem 'sentry-raven'
gem 'sidekiq'
gem 'sidekiq-cron'
gem 'skylight'
gem 'pry-rails'

Expand Down
12 changes: 11 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ GEM
responders
warden (~> 1.2.3)
erubis (2.7.0)
et-orbi (1.1.6)
tzinfo
execjs (2.7.0)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
Expand All @@ -104,6 +106,9 @@ GEM
formtastic (3.1.5)
actionpack (>= 3.2.13)
formtastic_i18n (0.6.0)
fugit (1.1.6)
et-orbi (~> 1.1, >= 1.1.6)
raabro (~> 1.1)
geocoder (1.4.3)
gibbon (3.0.1)
faraday (>= 0.9.1)
Expand Down Expand Up @@ -185,6 +190,7 @@ GEM
pry (>= 0.10.4)
public_suffix (3.0.0)
puma (3.8.2)
raabro (1.1.6)
rack (2.0.5)
rack-cors (0.4.1)
rack-protection (2.0.3)
Expand Down Expand Up @@ -251,6 +257,9 @@ GEM
connection_pool (~> 2.2, >= 2.2.2)
rack-protection (>= 1.5.0)
redis (>= 3.3.5, < 5)
sidekiq-cron (1.0.4)
fugit (~> 1.1)
sidekiq (>= 4.2.1)
skylight (1.5.0)
activesupport (>= 3.0.0)
spring (2.0.1)
Expand Down Expand Up @@ -313,11 +322,12 @@ DEPENDENCIES
sendgrid-ruby
sentry-raven
sidekiq
sidekiq-cron
skylight
spring
spring-watcher-listen (~> 2.0.0)
vcr (~> 3.0, >= 3.0.3)
webmock (~> 3.0, >= 3.0.1)

BUNDLED WITH
1.16.4
1.16.5
11 changes: 11 additions & 0 deletions app/jobs/github_collect_statistics_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class GithubCollectStatisticsJob
include Sidekiq::Worker

def perform
limit = GitHub::Client.new.rate_limit
logger.info("Github Ratelimit: #{limit}")

GitHub::PullRequests.new.fetch_and_save!
GitHub::Issues.new.fetch_and_save!
end
end
5 changes: 5 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'sidekiq'
require 'sidekiq-cron'

schedule_file = 'config/job_schedule.yml'

Sidekiq.configure_server do |config|
# https://stackoverflow.com/questions/28412913/disable-automatic-retry-with-activejob-used-with-sidekiq
Expand All @@ -10,4 +13,6 @@
}
Rails.logger = Sidekiq::Logging.logger
ActiveRecord::Base.logger = Sidekiq::Logging.logger

Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file) if File.exist?(schedule_file)
end
28 changes: 28 additions & 0 deletions config/job_schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Examples of job configurations

#my_first_job:
# cron: "*/5 * * * *"
# class: "HardWorker"
# queue: hard_worker
#
#second_job:
# cron: "*/30 * * * *" # execute at every 30 minutes
# class: "HardWorker"
# queue: hard_worker_long
# args:
# hard: "stuff"


# At 04:00 every day run the meetup member sync job
meetup_member_sync_job:
#cron: "0 4 * * *"
cron: "0 0 5 31 2 ?" # only run Feb 31
class: "MeetupMemberSyncJob"
queue: "default"

# At 03:00 every day run the github collect statistics job
github_collect_statistics_job:
#cron: "0 3 * * *"
cron: "0 0 5 31 2 ?" # only run Feb 31
class: "GithubCollectStatisticsJob"
queue: "default"
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
ActiveAdmin.routes(self)

require 'sidekiq/web'
authenticate :admin_user, ->(u) { u.role.super_admin? } do
require 'sidekiq/cron/web'
authenticate :admin_user, ->(u) { u.role.admin_accessible? } do
mount Sidekiq::Web => '/admin/sidekiq'
end

Expand Down
15 changes: 0 additions & 15 deletions lib/tasks/git_hub.rake

This file was deleted.