lazylead 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.docs/duedate_expired.md +1 -1
- data/.rubocop.yml +18 -3
- data/Gemfile +1 -1
- data/Guardfile +1 -1
- data/Rakefile +1 -1
- data/bin/lazylead +1 -1
- data/lazylead.gemspec +11 -11
- data/lib/lazylead.rb +2 -2
- data/lib/lazylead/allocated.rb +1 -1
- data/lib/lazylead/cc.rb +1 -1
- data/lib/lazylead/cli/app.rb +1 -1
- data/lib/lazylead/confluence.rb +1 -1
- data/lib/lazylead/email.rb +1 -1
- data/lib/lazylead/exchange.rb +1 -1
- data/lib/lazylead/home.rb +1 -1
- data/lib/lazylead/log.rb +1 -1
- data/lib/lazylead/model.rb +1 -1
- data/lib/lazylead/opts.rb +6 -3
- data/lib/lazylead/postman.rb +1 -1
- data/lib/lazylead/requires.rb +38 -0
- data/lib/lazylead/salt.rb +1 -1
- data/lib/lazylead/schedule.rb +1 -1
- data/lib/lazylead/smtp.rb +1 -1
- data/lib/lazylead/system/empty.rb +1 -1
- data/lib/lazylead/system/fake.rb +1 -1
- data/lib/lazylead/system/jira.rb +19 -18
- data/lib/lazylead/system/synced.rb +1 -1
- data/lib/lazylead/task/accuracy/accuracy.rb +15 -18
- data/lib/lazylead/task/accuracy/affected_build.rb +1 -1
- data/lib/lazylead/task/accuracy/attachment.rb +1 -1
- data/lib/lazylead/task/accuracy/environment.rb +1 -1
- data/lib/lazylead/task/accuracy/logs.rb +1 -1
- data/lib/lazylead/task/accuracy/onlyll.rb +1 -1
- data/lib/lazylead/task/accuracy/records.rb +1 -1
- data/lib/lazylead/task/accuracy/requirement.rb +1 -1
- data/lib/lazylead/task/accuracy/servers.rb +1 -1
- data/lib/lazylead/task/accuracy/stacktrace.rb +1 -1
- data/lib/lazylead/task/accuracy/testcase.rb +1 -1
- data/lib/lazylead/task/accuracy/wiki.rb +1 -1
- data/lib/lazylead/task/{alert.rb → alert/alert.rb} +6 -6
- data/lib/lazylead/task/alert/alertif.rb +75 -0
- data/lib/lazylead/task/alert/changed_to.rb +58 -0
- data/lib/lazylead/task/assignment.rb +1 -1
- data/lib/lazylead/task/confluence_ref.rb +1 -1
- data/lib/lazylead/task/echo.rb +1 -1
- data/lib/lazylead/task/fix_version.rb +1 -1
- data/lib/lazylead/task/loading.rb +94 -0
- data/lib/lazylead/task/missing_comment.rb +1 -1
- data/lib/lazylead/task/propagate_down.rb +3 -3
- data/lib/lazylead/task/savepoint.rb +1 -1
- data/lib/lazylead/task/svn/diff.rb +1 -1
- data/lib/lazylead/task/svn/grep.rb +1 -1
- data/lib/lazylead/task/svn/touch.rb +1 -1
- data/lib/lazylead/version.rb +2 -2
- data/lib/messages/accuracy.erb +1 -1
- data/lib/messages/alertif.erb +134 -0
- data/lib/messages/created_recently.erb +110 -0
- data/lib/messages/loading.erb +117 -0
- data/readme.md +3 -3
- data/test/lazylead/allocated_test.rb +1 -1
- data/test/lazylead/cc_test.rb +1 -1
- data/test/lazylead/cli/app_test.rb +2 -2
- data/test/lazylead/confluence_test.rb +1 -1
- data/test/lazylead/exchange_test.rb +1 -1
- data/test/lazylead/model_test.rb +1 -1
- data/test/lazylead/opts_test.rb +1 -1
- data/test/lazylead/postman_test.rb +1 -1
- data/test/lazylead/salt_test.rb +1 -1
- data/test/lazylead/smoke_test.rb +1 -1
- data/test/lazylead/smtp_test.rb +1 -1
- data/test/lazylead/system/jira_test.rb +10 -1
- data/test/lazylead/task/accuracy/accuracy_test.rb +1 -1
- data/test/lazylead/task/accuracy/affected_build_test.rb +1 -1
- data/test/lazylead/task/accuracy/attachment_test.rb +1 -1
- data/test/lazylead/task/accuracy/environment_test.rb +1 -1
- data/test/lazylead/task/accuracy/logs_test.rb +1 -1
- data/test/lazylead/task/accuracy/onlyll_test.rb +1 -1
- data/test/lazylead/task/accuracy/records_test.rb +1 -1
- data/test/lazylead/task/accuracy/score_test.rb +2 -2
- data/test/lazylead/task/accuracy/servers_test.rb +1 -1
- data/test/lazylead/task/accuracy/stacktrace_test.rb +1 -1
- data/test/lazylead/task/accuracy/testcase_test.rb +1 -1
- data/test/lazylead/task/accuracy/wiki_test.rb +1 -1
- data/test/lazylead/task/alert/alertif_test.rb +54 -0
- data/test/lazylead/task/{assignee_alert_test.rb → alert/assignee_alert_test.rb} +10 -10
- data/test/lazylead/task/alert/changed_to_test.rb +42 -0
- data/test/lazylead/task/assignment_test.rb +1 -1
- data/test/lazylead/task/confluence_ref_test.rb +1 -1
- data/test/lazylead/task/created_recently_test.rb +53 -0
- data/test/lazylead/task/duedate_test.rb +2 -2
- data/test/lazylead/task/echo_test.rb +1 -1
- data/test/lazylead/task/fix_version_test.rb +1 -1
- data/test/lazylead/task/loading_test.rb +54 -0
- data/test/lazylead/task/missing_comment_test.rb +1 -1
- data/test/lazylead/task/propagate_down_test.rb +1 -1
- data/test/lazylead/task/savepoint_test.rb +1 -1
- data/test/lazylead/task/svn/diff_test.rb +1 -1
- data/test/lazylead/task/svn/grep_test.rb +1 -1
- data/test/lazylead/task/svn/touch_test.rb +1 -1
- data/test/lazylead/version_test.rb +1 -1
- data/test/sqlite_test.rb +1 -1
- data/test/test.rb +1 -1
- data/upgrades/sqlite/001-install-main-lazylead-tables.sql +1 -1
- data/upgrades/sqlite/999.testdata.sql +1 -1
- metadata +37 -22
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -27,6 +27,7 @@ require_relative "../../opts"
|
|
27
27
|
require_relative "../../email"
|
28
28
|
require_relative "../../version"
|
29
29
|
require_relative "../../postman"
|
30
|
+
require_relative "../../requires"
|
30
31
|
|
31
32
|
module Lazylead
|
32
33
|
module Task
|
@@ -43,15 +44,14 @@ module Lazylead
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def run(sys, postman, opts)
|
46
|
-
|
47
|
-
rules = opts.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
postman.send opts.merge(tickets: raised) unless raised.empty?
|
47
|
+
Requires.new(__dir__).load
|
48
|
+
opts[:rules] = opts.construct("rules")
|
49
|
+
opts[:total] = opts[:rules].sum(&:score)
|
50
|
+
opts[:tickets] = sys.issues(opts["jql"], opts.jira_defaults)
|
51
|
+
.map { |i| Score.new(i, opts) }
|
52
|
+
.each(&:evaluate)
|
53
|
+
.each(&:post)
|
54
|
+
postman.send(opts) unless opts[:tickets].empty?
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -60,19 +60,16 @@ module Lazylead
|
|
60
60
|
class Score
|
61
61
|
attr_reader :issue, :total, :score, :accuracy
|
62
62
|
|
63
|
-
def initialize(issue, opts
|
63
|
+
def initialize(issue, opts)
|
64
64
|
@issue = issue
|
65
|
-
@link = opts["docs"]
|
66
65
|
@opts = opts
|
67
|
-
@rules = rules
|
68
66
|
end
|
69
67
|
|
70
68
|
# Estimate the ticket score and accuracy.
|
71
69
|
# Accuracy is a percentage between current score and maximum possible value.
|
72
70
|
def evaluate(digits = 2)
|
73
|
-
@
|
74
|
-
@
|
75
|
-
@accuracy = (score / @total * 100).round(digits)
|
71
|
+
@score = @opts[:rules].select { |r| r.passed(@issue) }.sum(&:score)
|
72
|
+
@accuracy = (score / @opts[:total] * 100).round(digits)
|
76
73
|
end
|
77
74
|
|
78
75
|
# Post the comment with score and accuracy to the ticket.
|
@@ -103,11 +100,11 @@ module Lazylead
|
|
103
100
|
|
104
101
|
# Link to ticket formatting rules
|
105
102
|
def docs_link
|
106
|
-
if @
|
103
|
+
if @opts["docs"].nil? || @opts["docs"].blank?
|
107
104
|
""
|
108
105
|
else
|
109
106
|
"The requirements/examples of ticket formatting rules you may find " \
|
110
|
-
"[here|#{@
|
107
|
+
"[here|#{@opts['docs']}]."
|
111
108
|
end
|
112
109
|
end
|
113
110
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -22,11 +22,11 @@
|
|
22
22
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
23
|
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
|
25
|
-
require_relative "
|
26
|
-
require_relative "
|
27
|
-
require_relative "
|
28
|
-
require_relative "
|
29
|
-
require_relative "
|
25
|
+
require_relative "../../log"
|
26
|
+
require_relative "../../opts"
|
27
|
+
require_relative "../../email"
|
28
|
+
require_relative "../../version"
|
29
|
+
require_relative "../../postman"
|
30
30
|
|
31
31
|
module Lazylead
|
32
32
|
#
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require_relative "../../log"
|
26
|
+
require_relative "../../opts"
|
27
|
+
require_relative "../../email"
|
28
|
+
require_relative "../../postman"
|
29
|
+
require_relative "../../requires"
|
30
|
+
|
31
|
+
module Lazylead
|
32
|
+
module Task
|
33
|
+
#
|
34
|
+
# Send an alert if expected conditions are met.
|
35
|
+
#
|
36
|
+
# The task supports the following features:
|
37
|
+
# - fetch issues from remote ticketing system by query
|
38
|
+
# - evaluate set of rules for each ticket
|
39
|
+
# - send an email
|
40
|
+
# @todo #334:DEV AlertIf should support rules for bulk issues. For now each rule works per issue
|
41
|
+
class AlertIf
|
42
|
+
def run(sys, postman, opts)
|
43
|
+
Requires.new(__dir__).load
|
44
|
+
opts[:rules] = opts.construct("rules")
|
45
|
+
sys.issues(opts["jql"], opts.jira_defaults.merge(expand: "changelog"))
|
46
|
+
.map { |i| When.new(i, opts) }
|
47
|
+
.select(&:matches)
|
48
|
+
.group_by(&:assignee)
|
49
|
+
.each { |a, t| postman.send opts.merge(to: a.email, addressee: a.name, tickets: t) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# The conditions for the issue inspection.
|
54
|
+
class When
|
55
|
+
extend Forwardable
|
56
|
+
def_delegators :@issue, :key, :url, :fields, :status, :duedate, :priority, :reporter,
|
57
|
+
:assignee, :summary, :comments
|
58
|
+
|
59
|
+
def initialize(issue, opts)
|
60
|
+
@issue = issue
|
61
|
+
@opts = opts
|
62
|
+
end
|
63
|
+
|
64
|
+
def matches
|
65
|
+
return false if @opts[:rules].nil?
|
66
|
+
@opts[:rules].all? { |r| r.passed(@issue, @opts) }
|
67
|
+
end
|
68
|
+
|
69
|
+
# The last comment in ticket
|
70
|
+
def last
|
71
|
+
@last ||= @issue.comments.last
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require_relative "../../opts"
|
26
|
+
|
27
|
+
module Lazylead
|
28
|
+
#
|
29
|
+
# Gives true when ticket status changed to expected status(es).
|
30
|
+
#
|
31
|
+
class ChangedTo
|
32
|
+
def initialize(field, expected)
|
33
|
+
@field = field
|
34
|
+
@expected = expected
|
35
|
+
end
|
36
|
+
|
37
|
+
def passed(issue, opts)
|
38
|
+
return false if issue.nil? || opts.nil? || opts[@expected].nil? || @field.nil?
|
39
|
+
last = last_change(issue)
|
40
|
+
opts.slice(@expected, ",").any? { |s| s.eql? last }
|
41
|
+
end
|
42
|
+
|
43
|
+
# Detect the last change of expected field in issue history
|
44
|
+
def last_change(issue)
|
45
|
+
issue.history
|
46
|
+
.reverse
|
47
|
+
.find { |h| h["items"].any? { |i| i["field"] == @field } }["items"]
|
48
|
+
.find { |h| h["field"] == @field }["toString"]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Check that last status change has expected value.
|
53
|
+
class ToStatus < Lazylead::ChangedTo
|
54
|
+
def initialize
|
55
|
+
super "status", "to_status"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
data/lib/lazylead/task/echo.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2019-
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"),
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2021 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require "date"
|
26
|
+
require_relative "../log"
|
27
|
+
require_relative "../opts"
|
28
|
+
require_relative "../system/jira"
|
29
|
+
|
30
|
+
module Lazylead
|
31
|
+
module Task
|
32
|
+
# Notification about team loading
|
33
|
+
class Loading
|
34
|
+
def initialize(log = Log.new)
|
35
|
+
@log = log
|
36
|
+
end
|
37
|
+
|
38
|
+
def run(sys, postman, opts)
|
39
|
+
assignments = sys.issues(opts["jql"])
|
40
|
+
.group_by(&:assignee)
|
41
|
+
.map { |user, tasks| [user.id, Teammate.new(user, tasks)] }
|
42
|
+
.to_h
|
43
|
+
opts.slice("team", ",")
|
44
|
+
.map { |m| m.split(":") }
|
45
|
+
.each { |id, name| assignments[id] = Free.new(id, name) unless assignments.key? id }
|
46
|
+
return if assignments.empty?
|
47
|
+
postman.send opts.merge(assignments: assignments)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# The teammate's tickets.
|
52
|
+
class Teammate
|
53
|
+
extend Forwardable
|
54
|
+
def_delegators :@user, :id, :name
|
55
|
+
def_delegators :@tasks, :size
|
56
|
+
|
57
|
+
def initialize(user, tasks = [])
|
58
|
+
@user = user
|
59
|
+
@tasks = tasks
|
60
|
+
end
|
61
|
+
|
62
|
+
def free?
|
63
|
+
return true if @tasks.nil?
|
64
|
+
@tasks.empty?
|
65
|
+
end
|
66
|
+
|
67
|
+
def next
|
68
|
+
@tasks.reject { |t| t.duedate.nil? }.map { |t| t.duedate.to_date }.min
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_s
|
72
|
+
"#{id} has #{total} tasks"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# The teammate without tasks.
|
77
|
+
class Free
|
78
|
+
attr_reader :id, :name
|
79
|
+
|
80
|
+
def initialize(id, name)
|
81
|
+
@id = id
|
82
|
+
@name = name
|
83
|
+
end
|
84
|
+
|
85
|
+
def free?
|
86
|
+
true
|
87
|
+
end
|
88
|
+
|
89
|
+
def next
|
90
|
+
""
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|