-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
139 lines (113 loc) · 3.28 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# frozen_string_literal: true
require 'rapidjson/json_gem'
require 'honeybadger'
require 'aws-sdk-s3'
require 'date'
require 'minitest/test_task'
Minitest::TestTask.create
require_relative 'logging'
require_relative 'db'
require_relative 'fetchers/towns'
require_relative 'fetchers/teams'
require_relative 'fetchers/players'
require_relative 'fetchers/base_rosters'
require_relative 'fetchers/tournament/details'
require_relative 'fetchers/tournament/results'
require_relative 'fetchers/tournament/rosters'
require_relative 'standalone/season'
require_relative 'backup/sqlite'
require_relative 'backup/postgres'
require_relative 'exporters/continuity'
Honeybadger.configure do |config|
config.exceptions.rescue_rake = true
end
logger = Loggable.logger
namespace :towns do
task :fetch_all do
fetch_all_towns
end
end
namespace :teams do
task :fetch_all do
fetch_all_teams
end
end
namespace :players do
task :fetch_all do
fetch_all_players
end
end
namespace :base_rosters do
task :fetch_id_range, [:first_id, :number_of_ids] do |_t, args|
last_id = if args[:number_of_ids].nil?
max_team_id + 500
else
args[:first_id].to_i + args[:number_of_ids].to_i - 1
end
ids = (args[:first_id].to_i..last_id.to_i).to_a
logger.info "fetching rosters for ids from #{args[:first_id]} to #{last_id}"
BaseRostersFetcher.new(ids:).run
end
task :fetch_for_teams_in_rating_tournaments do
BaseRostersFetcher.new(ids: teams_that_played_rating_tournaments).run
end
end
namespace :tournaments do
task :details_for_all_tournaments do
TournamentDetailsFetcher.new(category: :all).run
end
task :details_for_rating_tournaments do
TournamentDetailsFetcher.new(category: :maii).run
end
task :details_for_recent_tournaments do
TournamentDetailsFetcher.new(category: :recent).run
end
task :details_for_recently_updated_tournaments do
TournamentDetailsFetcher.new(category: :recently_updated).run
end
task :results_for_all do
TournamentResultsFetcher.new(ids: all_tournaments).run
end
task :results_for_rating do
TournamentResultsFetcher.new(ids: rating_tournaments).run
end
task :results_for_recent, [:days] do |_t, args|
ids = recent_tournaments(days: args[:days].to_i)
TournamentResultsFetcher.new(ids:).run
end
task :results_for_single_tournament, [:id] do |_t, args|
TournamentResultsFetcher.new(ids: [args[:id].to_i]).run
end
task :rosters_for_all do
TournamentRostersFetcher.new(ids: all_tournaments).run
end
task :rosters_for_rating do
TournamentRostersFetcher.new(ids: rating_tournaments).run
end
task :rosters_for_recent, [:days] do |_t, args|
ids = recent_tournaments(days: args[:days].to_i)
TournamentRostersFetcher.new(ids:).run
end
task :rosters_for_single_tournament, [:id] do |_t, args|
TournamentRostersFetcher.new(ids: [args[:id].to_i]).run
end
end
namespace :seasons do
task :fetch_all do
SeasonsImporter.new.run
end
end
task :vacuum do
logger.info 'starting VACUUM FULL'
vacuum_full
logger.info 'finished VACUUM FULL'
end
namespace :export do
task :continuity do
year_ago = Time.now - (60 * 60 * 24 * 365)
WrongTeamIDsExporter.new(with_start_date_after: year_ago).run
end
end
at_exit do
Honeybadger.stop
end