Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
🔧 Reenable telegram notifications and change scraping frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv committed Jun 26, 2022
1 parent 02f4592 commit b8c34d8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
8 changes: 8 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"cron": [
{
"command": "bundle exec rake admin:import_data",
"schedule": "1 * * * *"
},
{
"command": "bundle exec rake admin:scrap_pending_items_data",
"schedule": "3,33 * * * *"
},
{
"command": "bundle exec rake admin:update_games_visits",
"schedule": "3 8 * * *"
Expand Down
15 changes: 1 addition & 14 deletions app/operations/admin/import_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ def call
wrap_task("Import items") { RawItems::Import.call }
wrap_task("Import prices") { Prices::Import.call }
wrap_task("Update flags") { Items::UpdateFlags.call }

[scrap_thread, telegram_thread].map(&:join)
wrap_task("Send Telegram notifications") { EventDispatches::SendToTelegram.call } if Rails.env.production?
end

private
Expand All @@ -19,17 +18,5 @@ def wrap_task(task_name)

Sentry.capture_exception(e, extra: { task: task_name })
end

def telegram_thread
Thread.new do
wrap_task("Send Telegram notifications") { EventDispatches::SendToTelegram.call } if Rails.env.production?
end
end

def scrap_thread
Thread.new do
wrap_task("Scrap games website data") { Items::ScrapPendingItemsData.call }
end
end
end
end
4 changes: 4 additions & 0 deletions lib/tasks/import_data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class DataTasks
Admin::ImportData.call
end

task scrap_pending_items_data: :environment do
Items::ScrapPendingItemsData.call
end

task update_games_visits: :environment do
Items::UpdateVisits.call
end
Expand Down
1 change: 0 additions & 1 deletion spec/operations/admin/import_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
RawItems::Import,
Prices::Import,
Items::UpdateFlags,
Items::ScrapPendingItemsData,
EventDispatches::SendToTelegram
]
end
Expand Down

0 comments on commit b8c34d8

Please sign in to comment.