-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
68 lines (50 loc) · 1.56 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "app"
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/test_*.rb"]
end
task default: :test
task :update_games do
require_relative "config/boot"
epic_url = "https://store-site-backend-static.ak.epicgames.com".freeze
adapter = EpicAdapter.new(epic_url)
UpdateGames.new(adapter).call
end
task :notify_new_promotions do
require_relative "config/boot"
NotifyTelegram.new.call
end
namespace :db do
task :create, [:db_name] do |t, args|
require "sequel"
db = Sequel.connect(ENV["POSTGRES_URL"].to_s)
db.run("DROP DATABASE IF EXISTS #{args[:db_name]}")
db.run("CREATE DATABASE #{args[:db_name]}")
end
task :migrate do
require "sequel"
require "sequel/extensions/migration"
Sequel::Migrator.run(Sequel.connect(ENV["DATABASE_URL"].to_s), "db/migrations")
end
namespace :test do
task :migrate do
require "sequel"
require "sequel/extensions/migration"
test_database = ENV["DATABASE_TEST_URL"]
db = Sequel.connect(ENV["POSTGRES_URL"].to_s)
db.run("DROP DATABASE IF EXISTS \"#{test_database}\"")
db.run("CREATE DATABASE \"#{test_database}\"")
Sequel::Migrator.run(Sequel.connect(test_database), "db/migrations")
end
end
namespace :seed do
task :past_promotions do
require_relative "config/boot"
require_relative "db/load_past_promotions"
api_url = "https://store.epicgames.com/graphql"
LoadPastPromotions.new("./db/past_promotions.txt", api_url).call
end
end
end