-
Notifications
You must be signed in to change notification settings - Fork 1
/
import.rake
157 lines (135 loc) · 4.96 KB
/
import.rake
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# frozen_string_literal: true
namespace :import do
namespace :cancel_or_reject_journeys do
desc "Cancels or rejects journeys using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
journey_id: :id,
move_id: :move_id,
event_timestamp: :timeofendingevent,
}
print Imports::CancelOrRejectJourneys.call(csv_path:, columns:).summary
end
end
namespace :delete_events do
desc "Deletes events which are invalid a vehicle using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
event_id: :moveeventid,
eventable_id: :moveid,
}
print Imports::DeleteEvents.call(csv_path:, columns:).summary
end
end
namespace :events_incorrect_occurred_at do
desc "Import events which have an incorrect occurred at time using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
event_id: :moveeventid,
eventable_id: :moveid,
occurred_at: :timetoupdate,
}
print Imports::EventsIncorrectOccurredAt.call(csv_path:, columns:).summary
end
end
namespace :journeys_missing_vehicle do
desc "Import journeys which are missing a vehicle using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
journey_id: :basmmojjourneyid,
move_id: :basmmojmoveid,
vehicle_registration: :sers_vehiclereg,
}
print Imports::JourneysMissingVehicle.call(csv_path:, columns:).summary
end
end
namespace :journeys_without_ending_state do
desc "Import journeys which don't have an ending state using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
journey_id: :basm_id,
move_id: :basm_moveid,
old_state: :basm_state,
new_state: :sers_status,
}
print Imports::JourneysWithoutEndingState.call(csv_path:, columns:).summary
end
end
namespace :missing_journey_ending_events do
desc "Import events for journeys which are missing an ending event using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
journey_id: :basm_id,
move_id: :basm_moveid,
new_state: :sers_status,
event_timestamp: :basm_client_timestamp,
}
print Imports::MissingJourneyEndingEvents.call(csv_path:, columns:).summary
end
end
namespace :missing_journey_start_events do
desc "Import events for journeys which are missing a start event using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
journey_id: :journeyid,
event_timestamp: :timeofjourneystartevent,
}
print Imports::MissingJourneyStartEvents.call(csv_path:, columns:).summary
end
end
namespace :missing_move_ending_events do
desc "Import events for moves which are missing an ending event using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
move_id: :basmmojmoveid,
event_type: :sersendingevent,
event_timestamp: :timeofendingevent,
cancellation_reason: :cancellationreason,
rejection_reason: :cancellationreason,
}
print Imports::MissingMoveEndingEvents.call(csv_path:, columns:).summary
end
end
namespace :missing_move_start_events do
desc "Import events for moves which are missing a start event using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
move_id: :basmmojmoveid,
event_timestamp: :timeofmovestartevent,
}
print Imports::MissingMoveStartEvents.call(csv_path:, columns:).summary
end
end
namespace :moves_without_ending_state do
desc "Import moves which don't have an ending state using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
move_id: :basmmojmoveid,
old_status: :basmmovestatus,
new_status: :sersstatus,
}
print Imports::MovesWithoutEndingState.call(csv_path:, columns:).summary
end
end
namespace :moves_without_to_location do
desc "Import moves which don't have a to location using Serco's spreadsheets."
task :serco, [:csv_path] => :environment do |_, args|
csv_path = args.fetch(:csv_path)
columns = {
move_id: :id,
location_key: :mojdestlocationcode,
}
print Imports::MovesWithoutToLocation.call(csv_path:, columns:).summary
end
end
end