blob: fe010ffd95f4a8124b3fa44fb5bd279de4a01d14 (
plain)
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
|
module Cron
class << self
def every_day_at_3AM
sync_reflex
end
def every_day_at_4AM
sync_codifligne
end
def every_hour
sync_organizations
sync_users
end
def every_5_minutes
check_import_operations
check_ccset_operations
end
private
def sync_organizations
begin
Organisation.portail_sync
rescue => e
Rails.logger.error(e.inspect)
end
end
def sync_users
begin
User.portail_sync
rescue => e
Rails.logger.error(e.inspect)
end
end
def sync_reflex
begin
sync = StopAreaReferential.find_by(name: 'Reflex').stop_area_referential_syncs.build
raise "reflex:sync aborted - There is already an synchronisation in progress" unless sync.valid?
sync.save
rescue => e
Rails.logger.warn(e.message)
end
end
def sync_codifligne
begin
sync = LineReferential.find_by(name: 'CodifLigne').line_referential_syncs.build
raise "Codifligne:sync aborted - There is already an synchronisation in progress" unless sync.valid?
sync.save
rescue => e
Rails.logger.warn(e.message)
end
end
def check_ccset_operations
begin
ParentNotifier.new(ComplianceCheckSet).notify_when_finished
ComplianceCheckSet.abort_old
rescue => e
Rails.logger.error(e.inspect)
end
end
def check_import_operations
begin
ParentNotifier.new(Import::Base).notify_when_finished
Import::Netex.abort_old
rescue => e
Rails.logger.error(e.inspect)
end
end
end
end
|