help_desk_dashboard 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/help_desk_dashboard/dashboard_generator.rb +20 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/app_config.rb +0 -0
- data/lib/help_desk_dashboard/lib/data_file_generator.rb +46 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/provider_factory.rb +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/providers/service-desk-plus/8.1/provider.rb +0 -0
- data/lib/help_desk_dashboard/lib/providers/track-it/2003.10.1/provider.rb +20 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/css/bootstrap-responsive.css +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/css/bootstrap-responsive.min.css +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/css/bootstrap.css +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/css/bootstrap.min.css +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/img/glyphicons-halflings.png +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/js/bootstrap.js +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/js/bootstrap.min.js +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/css/app.css +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/js/app.js +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/js/jquery-1.10.1.min.js +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/js/moment.min.js +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/config.ru +0 -0
- data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/index.html +0 -0
- data/lib/help_desk_dashboard.rb +1 -0
- metadata +36 -43
- data/bin/help_desk_dashboard.rb +0 -38
- data/lib/help-desk-dashboard/extensions.rb +0 -6
- data/lib/help-desk-dashboard/providers/track-it/2003.10.1/navigator.rb +0 -13
- data/lib/help-desk-dashboard/providers/track-it/2003.10.1/parallel_request_scraper.rb +0 -42
- data/lib/help-desk-dashboard/providers/track-it/2003.10.1/provider.rb +0 -26
- data/lib/help-desk-dashboard/providers/track-it/2003.10.1/request_scraper.rb +0 -48
- data/lib/help-desk-dashboard/providers/track-it/2003.10.1/user_operations.rb +0 -40
- data/lib/help-desk-dashboard/providers/track-it/2003.10.1/user_request_scraper.rb +0 -33
- data/lib/help-desk-dashboard/web_generator.rb +0 -27
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require_relative 'lib/app_config'
|
3
|
+
require_relative 'lib/data_file_generator'
|
4
|
+
|
5
|
+
class DashboardGenerator
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
@config = AppConfig.new config
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate
|
12
|
+
output_dir = @config[:output_dir]
|
13
|
+
FileUtils.mkdir_p output_dir
|
14
|
+
data_file_generator = DataFileGenerator.new @config, File.join(output_dir, 'data')
|
15
|
+
data_file_generator.generate
|
16
|
+
source_dir = File.join File.dirname(__FILE__), 'lib', 'web'
|
17
|
+
FileUtils.cp_r "#{source_dir}/.", output_dir
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
File without changes
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require_relative 'app_config'
|
3
|
+
require_relative 'provider_factory'
|
4
|
+
|
5
|
+
class DataFileGenerator
|
6
|
+
|
7
|
+
def initialize(config, output_dir)
|
8
|
+
@config = config
|
9
|
+
@output_dir = output_dir
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate
|
13
|
+
provider_factory = ProviderFactory.new
|
14
|
+
provider = provider_factory.create @config[:provider]
|
15
|
+
requests = provider.get_requests @config.users_with_password, threads: @config[:threads]
|
16
|
+
requests_by_submitter = requests.group_by { |r| r[:submitted_by] }
|
17
|
+
teams = @config[:teams].map do |team|
|
18
|
+
{
|
19
|
+
team_name: team[:name],
|
20
|
+
title: "#{team[:name]} Help Desk Requests",
|
21
|
+
requests: team[:members].map { |username| requests_by_submitter[username] }.flatten.compact
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
requests.each do |r|
|
26
|
+
user = config[:users].find { |u| u[:username] == r[:assigned_to] }
|
27
|
+
r[:assigned_to] = user[:name] if user
|
28
|
+
user = config[:users].find { |u| u[:username] == r[:submitted_by] }
|
29
|
+
r[:submitted_by] = user[:name] if user
|
30
|
+
end
|
31
|
+
|
32
|
+
FileUtils.rm_rf @output_dir
|
33
|
+
FileUtils.mkdir_p @output_dir
|
34
|
+
teams.each { |t| create_data_file t }
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def create_data_file(team)
|
41
|
+
file_name = "#{team[:team_name]}.json".downcase.gsub(' ', '-')
|
42
|
+
path = File.join @output_dir, file_name
|
43
|
+
File.write path, team.to_json
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
File without changes
|
data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/providers/service-desk-plus/8.1/provider.rb
RENAMED
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
require 'json'
|
3
|
+
require 'trackit_scraper/2003.10.1'
|
4
|
+
|
5
|
+
class Provider
|
6
|
+
|
7
|
+
def initialize(url)
|
8
|
+
@url = url
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_requests(users, options={})
|
12
|
+
Dir.mktmpdir do |output_dir|
|
13
|
+
options[:output_dir] = output_dir
|
14
|
+
trackit = TrackIt.new @url, users[0][:username], users[0][:password], options
|
15
|
+
trackit.scrape_requests_for_users users
|
16
|
+
return Dir["#{output_dir}/*"].map { |f| Hashie::Mash.new JSON.parse(File.read(f)) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
File without changes
|
File without changes
|
data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/css/bootstrap.css
RENAMED
File without changes
|
data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/css/bootstrap.min.css
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/js/bootstrap.js
RENAMED
File without changes
|
data/lib/{help-desk-dashboard → help_desk_dashboard/lib}/web/assets/bootstrap/js/bootstrap.min.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'help_desk_dashboard/dashboard_generator'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: help_desk_dashboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
16
|
-
requirement: &
|
16
|
+
requirement: &70198175013500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.0.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70198175013500
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70198175013020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,63 +32,56 @@ dependencies:
|
|
32
32
|
version: 1.7.7
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70198175013020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: rack
|
38
|
+
requirement: &70198175012560 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 1.5.2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70198175012560
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: trackit_scraper
|
49
|
+
requirement: &70198175012100 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.0.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70198175012100
|
58
58
|
description:
|
59
59
|
email: matthew-github@matthewriley.name
|
60
|
-
executables:
|
61
|
-
- help_desk_dashboard.rb
|
60
|
+
executables: []
|
62
61
|
extensions: []
|
63
62
|
extra_rdoc_files: []
|
64
63
|
files:
|
65
|
-
- lib/
|
66
|
-
- lib/
|
67
|
-
- lib/
|
68
|
-
- lib/
|
69
|
-
- lib/
|
70
|
-
- lib/
|
71
|
-
- lib/
|
72
|
-
- lib/
|
73
|
-
- lib/
|
74
|
-
- lib/
|
75
|
-
- lib/
|
76
|
-
- lib/
|
77
|
-
- lib/
|
78
|
-
- lib/
|
79
|
-
- lib/
|
80
|
-
- lib/
|
81
|
-
- lib/
|
82
|
-
- lib/
|
83
|
-
- lib/
|
84
|
-
- lib/
|
85
|
-
- lib/
|
86
|
-
- lib/help-desk-dashboard/web/assets/js/moment.min.js
|
87
|
-
- lib/help-desk-dashboard/web/config.ru
|
88
|
-
- lib/help-desk-dashboard/web/index.html
|
89
|
-
- lib/help-desk-dashboard/web_generator.rb
|
90
|
-
- !binary |-
|
91
|
-
YmluL2hlbHBfZGVza19kYXNoYm9hcmQucmI=
|
64
|
+
- lib/help_desk_dashboard/dashboard_generator.rb
|
65
|
+
- lib/help_desk_dashboard/lib/app_config.rb
|
66
|
+
- lib/help_desk_dashboard/lib/data_file_generator.rb
|
67
|
+
- lib/help_desk_dashboard/lib/provider_factory.rb
|
68
|
+
- lib/help_desk_dashboard/lib/providers/service-desk-plus/8.1/provider.rb
|
69
|
+
- lib/help_desk_dashboard/lib/providers/track-it/2003.10.1/provider.rb
|
70
|
+
- lib/help_desk_dashboard/lib/web/assets/bootstrap/css/bootstrap-responsive.css
|
71
|
+
- lib/help_desk_dashboard/lib/web/assets/bootstrap/css/bootstrap-responsive.min.css
|
72
|
+
- lib/help_desk_dashboard/lib/web/assets/bootstrap/css/bootstrap.css
|
73
|
+
- lib/help_desk_dashboard/lib/web/assets/bootstrap/css/bootstrap.min.css
|
74
|
+
- lib/help_desk_dashboard/lib/web/assets/bootstrap/img/glyphicons-halflings-white.png
|
75
|
+
- lib/help_desk_dashboard/lib/web/assets/bootstrap/img/glyphicons-halflings.png
|
76
|
+
- lib/help_desk_dashboard/lib/web/assets/bootstrap/js/bootstrap.js
|
77
|
+
- lib/help_desk_dashboard/lib/web/assets/bootstrap/js/bootstrap.min.js
|
78
|
+
- lib/help_desk_dashboard/lib/web/assets/css/app.css
|
79
|
+
- lib/help_desk_dashboard/lib/web/assets/js/app.js
|
80
|
+
- lib/help_desk_dashboard/lib/web/assets/js/jquery-1.10.1.min.js
|
81
|
+
- lib/help_desk_dashboard/lib/web/assets/js/moment.min.js
|
82
|
+
- lib/help_desk_dashboard/lib/web/config.ru
|
83
|
+
- lib/help_desk_dashboard/lib/web/index.html
|
84
|
+
- lib/help_desk_dashboard.rb
|
92
85
|
homepage:
|
93
86
|
licenses: []
|
94
87
|
post_install_message:
|
data/bin/help_desk_dashboard.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
$stdout.sync = true
|
2
|
-
|
3
|
-
require_relative '../lib/help-desk-dashboard/app_config'
|
4
|
-
require_relative '../lib/help-desk-dashboard/extensions'
|
5
|
-
require_relative '../lib/help-desk-dashboard/provider_factory'
|
6
|
-
require_relative '../lib/help-desk-dashboard/web_generator'
|
7
|
-
|
8
|
-
ENV['HTTP_PROXY'] = nil
|
9
|
-
ENV['CONFIG_FILE'] ||= 'config.json'
|
10
|
-
config = AppConfig.from_file ENV['CONFIG_FILE']
|
11
|
-
|
12
|
-
provider_factory = ProviderFactory.new
|
13
|
-
provider = provider_factory.create config[:provider]
|
14
|
-
requests = provider.get_requests(config.users_with_password, threads: config[:threads]).map do |r|
|
15
|
-
r.pick :id, :title, :status, :deadline, :assigned_to, :submitted_by, :submitted_on, :resolved_on
|
16
|
-
end
|
17
|
-
|
18
|
-
requests_by_submitter = requests.group_by { |r| r[:submitted_by] }
|
19
|
-
|
20
|
-
teams = config[:teams].map do |team|
|
21
|
-
{
|
22
|
-
team_name: team[:name],
|
23
|
-
title: "#{team[:name]} Help Desk Requests",
|
24
|
-
requests: team[:members].map { |username| requests_by_submitter[username] }.flatten
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
requests.each do |r|
|
29
|
-
user = config[:users].find { |u| u[:username] == r[:assigned_to] }
|
30
|
-
r[:assigned_to] = user[:name] if user
|
31
|
-
user = config[:users].find { |u| u[:username] == r[:submitted_by] }
|
32
|
-
r[:submitted_by] = user[:name] if user
|
33
|
-
end
|
34
|
-
|
35
|
-
generator = WebGenerator.new config[:output_dir]
|
36
|
-
generator.generate teams
|
37
|
-
|
38
|
-
puts 'Done.'
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
require 'watir-webdriver'
|
3
|
-
require_relative 'request_scraper'
|
4
|
-
require_relative 'user_operations'
|
5
|
-
|
6
|
-
class ParallelRequestScraper
|
7
|
-
|
8
|
-
def initialize(url, user, thread_limit)
|
9
|
-
@url = url
|
10
|
-
@user = user
|
11
|
-
@thread_limit = thread_limit
|
12
|
-
end
|
13
|
-
|
14
|
-
def scrape(request_ids)
|
15
|
-
queue = request_ids.clone
|
16
|
-
threads = []
|
17
|
-
requests = []
|
18
|
-
mutex = Mutex.new
|
19
|
-
|
20
|
-
@thread_limit.times do
|
21
|
-
threads << Thread.new do
|
22
|
-
b = Watir::Browser.new
|
23
|
-
navigator = Navigator.new b, @url
|
24
|
-
user_operations = UserOperations.new b, navigator
|
25
|
-
user_operations.login @user
|
26
|
-
request_scraper = RequestScraper.new b, navigator
|
27
|
-
until queue.empty?
|
28
|
-
id = nil
|
29
|
-
mutex.synchronize do
|
30
|
-
id = queue.pop
|
31
|
-
end
|
32
|
-
break unless id
|
33
|
-
requests << request_scraper.scrape(id)
|
34
|
-
end
|
35
|
-
b.close
|
36
|
-
end
|
37
|
-
end
|
38
|
-
threads.each { |t| t.join }
|
39
|
-
requests
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'watir-webdriver'
|
2
|
-
require_relative 'navigator'
|
3
|
-
require_relative 'parallel_request_scraper'
|
4
|
-
require_relative 'user_operations'
|
5
|
-
|
6
|
-
class Provider
|
7
|
-
|
8
|
-
def initialize(url)
|
9
|
-
@url = url
|
10
|
-
end
|
11
|
-
|
12
|
-
def get_requests(users, options={})
|
13
|
-
threads = options[:threads] || 5
|
14
|
-
|
15
|
-
b = Watir::Browser.new
|
16
|
-
navigator = Navigator.new b, @url
|
17
|
-
user_operations = UserOperations.new b, navigator
|
18
|
-
request_ids = user_operations.get_request_ids users
|
19
|
-
b.close
|
20
|
-
|
21
|
-
user = users.first
|
22
|
-
parallel_request_scraper = ParallelRequestScraper.new @url, user, threads
|
23
|
-
parallel_request_scraper.scrape request_ids
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
|
3
|
-
class RequestScraper
|
4
|
-
|
5
|
-
def initialize(b, navigator)
|
6
|
-
@b = b
|
7
|
-
@navigator = navigator
|
8
|
-
end
|
9
|
-
|
10
|
-
def scrape(id)
|
11
|
-
@navigator.goto "hd/ticket/euTicketView.ssp?ticket_id=#{id}&log=show"
|
12
|
-
cells = @b.tables[1].tds.to_a
|
13
|
-
{
|
14
|
-
id: @b.text.match(/Request #(\d+)/)[1],
|
15
|
-
title: cells[0].text,
|
16
|
-
status: cells[2].text,
|
17
|
-
service: cells[3].text,
|
18
|
-
request_type: cells[4].text,
|
19
|
-
time_spent: cells[6].text,
|
20
|
-
priority: cells[7].text,
|
21
|
-
deadline: Time.parse(cells[8].text),
|
22
|
-
submitted_to: cells[10].text,
|
23
|
-
submitted_by: cells[11].text.upcase,
|
24
|
-
submitted_on: Time.parse(cells[12].text),
|
25
|
-
assigned_to: cells[15].text.upcase,
|
26
|
-
assigned_by: cells[16].text,
|
27
|
-
assigned_on: Time.parse(cells[17].text),
|
28
|
-
department_id: cells[19].text,
|
29
|
-
closed_by: cells[20].text,
|
30
|
-
closed_on: cells[21].text == 'None' ? 'None' : Time.parse(cells[21].text)
|
31
|
-
}.merge scrape_resolved_data_from_audit_log
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def scrape_resolved_data_from_audit_log
|
37
|
-
rows = @b.tables[3].trs.to_a
|
38
|
-
index = rows.index { |r| r.text =~ /Resolved by/ }
|
39
|
-
return {} unless index
|
40
|
-
text = rows[index-1].text
|
41
|
-
matches = text.match /(.+) by (.+)/
|
42
|
-
{
|
43
|
-
resolved_on: Time.parse(matches[1]),
|
44
|
-
resolved_by: matches[2].upcase
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
class UserOperations
|
2
|
-
|
3
|
-
def initialize(b, navigator)
|
4
|
-
@b = b
|
5
|
-
@navigator = navigator
|
6
|
-
end
|
7
|
-
|
8
|
-
def login(user)
|
9
|
-
@navigator.goto 'hd/index.ssp'
|
10
|
-
@b.text_field(name: 'user_id').set user['username']
|
11
|
-
@b.text_field(name: 'user_pwd').set user['password']
|
12
|
-
@b.button(value: 'Log on').click
|
13
|
-
end
|
14
|
-
|
15
|
-
def get_request_ids(users)
|
16
|
-
users = [users].flatten
|
17
|
-
request_ids = users.map do |user|
|
18
|
-
login user
|
19
|
-
@navigator.goto 'hd/ticket/euTicketFind.ssp'
|
20
|
-
@b.button(value: 'Find').click
|
21
|
-
request_locations = get_request_locations
|
22
|
-
request_locations.map { |l| l.match(/ticket_id=(\d+)/)[1].to_i }
|
23
|
-
end
|
24
|
-
request_ids.flatten
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def get_request_locations
|
30
|
-
links = []
|
31
|
-
5.times do
|
32
|
-
links = @b.links(href: /euTicketView\.ssp\?ticket_id=/).to_a
|
33
|
-
break unless links.empty?
|
34
|
-
sleep 2
|
35
|
-
end
|
36
|
-
puts "No requests found.\n\n#{@b.html}" if links.empty?
|
37
|
-
links.map { |link| link.href }.reverse
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
require 'watir-webdriver'
|
3
|
-
require_relative 'request_scraper'
|
4
|
-
|
5
|
-
class UserRequestScraper
|
6
|
-
|
7
|
-
def initialize(b)
|
8
|
-
@b = b
|
9
|
-
end
|
10
|
-
|
11
|
-
def scrape
|
12
|
-
@b.goto 'hd/ticket/euTicketFind.ssp'
|
13
|
-
@b.button(value: 'Find').click
|
14
|
-
request_locations = get_request_locations
|
15
|
-
request_ids = request_locations.map { |l| l.match(/ticket_id=(\d+)/)[1].to_i }
|
16
|
-
request_scraper = RequestScraper.new @b
|
17
|
-
request_scraper.scrape_range request_ids
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def get_request_locations
|
23
|
-
links = []
|
24
|
-
5.times do
|
25
|
-
links = @b.links(href: /euTicketView\.ssp\?ticket_id=/).to_a
|
26
|
-
break unless links.empty?
|
27
|
-
sleep 2
|
28
|
-
end
|
29
|
-
puts "No requests found.\n\n#{@b.html}" if links.empty?
|
30
|
-
links.map { |link| link.href }.reverse
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'fileutils'; include FileUtils
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
class WebGenerator
|
5
|
-
|
6
|
-
def initialize(dest_dir)
|
7
|
-
@dest_dir = dest_dir
|
8
|
-
@dest_data_dir = File.join @dest_dir, 'data'
|
9
|
-
@source_dir = File.join File.dirname(__FILE__), 'web'
|
10
|
-
end
|
11
|
-
|
12
|
-
def generate(teams)
|
13
|
-
rm_rf @dest_dir
|
14
|
-
cp_r "#{@source_dir}/.", @dest_dir
|
15
|
-
mkdir_p @dest_data_dir
|
16
|
-
teams.each { |t| create_data_file t }
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def create_data_file(team)
|
22
|
-
file_name = "#{team[:team_name]}.json".downcase.gsub(' ', '-')
|
23
|
-
path = File.join @dest_data_dir, file_name
|
24
|
-
File.write path, team.to_json
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|