-
Notifications
You must be signed in to change notification settings - Fork 7
/
rutland.rb
68 lines (60 loc) · 2.05 KB
/
rutland.rb
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 'rest-client'
require_relative '../sentry_helper'
require_relative './ma_immunizations_registrations'
module Rutland
MAIN_URL = 'https://www.rrecc.us/vaccine'.freeze
TEACHER_URL = 'https://www.rrecc.us/k12'.freeze
def self.all_clinics(storage, logger)
logger.info '[Rutland] Checking site'
main_clinics(storage, logger) #+ teacher_clinics(storage, logger)
end
def self.main_clinics(storage, logger)
SentryHelper.catch_errors(logger, 'Rutland') do
res = RestClient.get(MAIN_URL).body
sections = res.split('<span style="text-decoration:underline;"')
sections.flat_map do |section|
additional_info = if section.start_with?('>')
match = />([\w\d\s-]+)[<(]/.match(section)
match && match[1].strip
end
sites = section.scan(%r{www\.maimmunizations\.org//reg/(\d+)"})
if sites.empty?
logger.info '[Rutland] No sites found'
[]
else
logger.info "[Rutland] Scanning #{sites.length} sites"
MaImmunizationsRegistrations.all_clinics(
'RUTLAND',
MAIN_URL,
sites.map { |clinic_num| "https://registrations.maimmunizations.org//reg/#{clinic_num[0]}" },
storage,
logger,
'Rutland',
additional_info
)
end
end
end
end
def self.teacher_clinics(storage, logger)
SentryHelper.catch_errors(logger, 'Rutland') do
res = RestClient.get(TEACHER_URL).body
sites = res.scan(%r{www\.maimmunizations\.org__reg_(\d+)&})
if sites.empty?
logger.info '[Rutland] No sites found'
[]
else
logger.info "[Rutland] Scanning #{sites.length} sites"
MaImmunizationsRegistrations.all_clinics(
'RUTLAND',
TEACHER_URL,
sites.map { |clinic_num| "https://registrations.maimmunizations.org//reg/#{clinic_num[0]}" },
storage,
logger,
'Rutland',
'teachers only'
)
end
end
end
end