help_desk_dashboard 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,7 @@ class DashboardGenerator
|
|
11
11
|
def generate
|
12
12
|
output_dir = @config[:output_dir]
|
13
13
|
FileUtils.mkdir_p output_dir
|
14
|
-
data_file_generator = DataFileGenerator.new @config
|
14
|
+
data_file_generator = DataFileGenerator.new @config
|
15
15
|
data_file_generator.generate
|
16
16
|
source_dir = File.join File.dirname(__FILE__), 'lib', 'web'
|
17
17
|
FileUtils.cp_r "#{source_dir}/.", output_dir
|
@@ -1,46 +1,69 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require_relative 'app_config'
|
3
2
|
require_relative 'provider_factory'
|
4
3
|
|
5
4
|
class DataFileGenerator
|
6
5
|
|
7
|
-
def initialize(config
|
6
|
+
def initialize(config)
|
8
7
|
@config = config
|
9
|
-
@
|
8
|
+
@provider_factory = ProviderFactory.new
|
10
9
|
end
|
11
10
|
|
12
11
|
def generate
|
13
|
-
|
14
|
-
provider = provider_factory.create @config[:provider]
|
12
|
+
provider = @provider_factory.create @config[:provider]
|
15
13
|
requests = provider.get_requests @config.users_with_password, threads: @config[:threads]
|
16
|
-
requests_by_submitter = requests.group_by { |r| r[:submitted_by] }
|
17
14
|
teams = @config[:teams].map do |team|
|
18
15
|
{
|
19
|
-
|
20
|
-
|
21
|
-
requests: team[:members].map { |username| requests_by_submitter[username] }.flatten.compact
|
16
|
+
title: title(team),
|
17
|
+
requests: team_requests(team, requests)
|
22
18
|
}
|
23
19
|
end
|
20
|
+
requests.each { |r| replace_username_with_name r, :submitted_by, :assigned_to }
|
21
|
+
FileUtils.mkdir_p output_dir
|
22
|
+
teams.each { |t| create_data_file t }
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
private
|
26
|
+
|
27
|
+
def title(team)
|
28
|
+
team[:title] || "#{team[:name]} Help Desk Dashboard"
|
29
|
+
end
|
30
|
+
|
31
|
+
def team_requests(team, requests)
|
32
|
+
members = team[:members].map { |m| username m }
|
33
|
+
requests.select { |r| members.include? username(r[:submitted_by]) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_username_with_name(request, *keys)
|
37
|
+
keys.each do |key|
|
38
|
+
username = username(request[key])
|
39
|
+
user = get_user username
|
40
|
+
request[key] = user[:name] if user
|
30
41
|
end
|
42
|
+
end
|
31
43
|
|
32
|
-
|
33
|
-
|
34
|
-
|
44
|
+
def get_user(username)
|
45
|
+
users_by_username[username][0]
|
46
|
+
end
|
35
47
|
|
48
|
+
def users_by_username
|
49
|
+
@users_by_username ||= @config[:users].group_by { |u| username u[:username] }
|
36
50
|
end
|
37
51
|
|
38
|
-
|
52
|
+
def username(username)
|
53
|
+
username.downcase
|
54
|
+
end
|
39
55
|
|
40
56
|
def create_data_file(team)
|
57
|
+
File.write data_file_path(team), team.to_json
|
58
|
+
end
|
59
|
+
|
60
|
+
def data_file_path(team)
|
41
61
|
file_name = "#{team[:team_name]}.json".downcase.gsub(' ', '-')
|
42
|
-
|
43
|
-
|
62
|
+
File.join output_dir, file_name
|
63
|
+
end
|
64
|
+
|
65
|
+
def output_dir
|
66
|
+
File.join @config[:output_dir], 'data'
|
44
67
|
end
|
45
68
|
|
46
69
|
end
|
@@ -13,7 +13,7 @@ function create_requests_table(requests) {
|
|
13
13
|
resolved_requests.push(request);
|
14
14
|
});
|
15
15
|
|
16
|
-
function
|
16
|
+
function sort_deadline_asc(r1, r2) {
|
17
17
|
var date1 = Date.parse(r1.deadline);
|
18
18
|
var date2 = Date.parse(r2.deadline);
|
19
19
|
if (date1 > date2) return 1;
|
@@ -21,17 +21,17 @@ function create_requests_table(requests) {
|
|
21
21
|
return 0;
|
22
22
|
}
|
23
23
|
|
24
|
-
function
|
25
|
-
var date1 = Date.parse(r1.
|
26
|
-
var date2 = Date.parse(r2.
|
24
|
+
function sort_resolved_on_desc(r1, r2) {
|
25
|
+
var date1 = Date.parse(r1.resolved_on);
|
26
|
+
var date2 = Date.parse(r2.resolved_on);
|
27
27
|
if (date1 > date2) return -1;
|
28
28
|
if (date1 < date2) return 1;
|
29
29
|
return 0;
|
30
30
|
}
|
31
31
|
|
32
|
-
overdue_requests.sort(
|
33
|
-
pending_requests.sort(
|
34
|
-
resolved_requests.sort(
|
32
|
+
overdue_requests.sort(sort_deadline_asc);
|
33
|
+
pending_requests.sort(sort_deadline_asc);
|
34
|
+
resolved_requests.sort(sort_resolved_on_desc);
|
35
35
|
requests = overdue_requests.concat(pending_requests, resolved_requests);
|
36
36
|
|
37
37
|
var table = $('<table class="requests"></table>');
|
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.6
|
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-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
16
|
-
requirement: &
|
16
|
+
requirement: &70255893994400 !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: *70255893994400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70255893993920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.7.7
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70255893993920
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rack
|
38
|
-
requirement: &
|
38
|
+
requirement: &70255893993460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.5.2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70255893993460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: trackit_scraper
|
49
|
-
requirement: &
|
49
|
+
requirement: &70255893993000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70255893993000
|
58
58
|
description:
|
59
59
|
email: matthew-github@matthewriley.name
|
60
60
|
executables: []
|
@@ -105,5 +105,5 @@ rubyforge_project:
|
|
105
105
|
rubygems_version: 1.8.15
|
106
106
|
signing_key:
|
107
107
|
specification_version: 3
|
108
|
-
summary: Generates a traffic light dashboard
|
108
|
+
summary: Generates a traffic light dashboard of help desk requests.
|
109
109
|
test_files: []
|