Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2997cf

Browse files
committed
per group tickets
1 parent ac082ae commit b2997cf

File tree

3 files changed

+65
-10
lines changed

3 files changed

+65
-10
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ module.exports = {
168168
"no-throw-literal": "error",
169169
"no-trailing-spaces": "error",
170170
"no-undef-init": "error",
171-
"no-undefined": "error",
171+
"no-undefined": "off",
172172
"no-underscore-dangle": "error",
173173
"no-unmodified-loop-condition": "error",
174174
"no-unneeded-ternary": "error",

support.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,37 @@ const actions = [
7070
reply: (message, output) => JSON.stringify(output, null, 4),
7171
},
7272
{
73-
action: (data, _message, username) => ({
74-
'tickets': data.tickets,
75-
'username': username.toLowerCase()
73+
action: (data, message, username) => ({
74+
'tickets': ticket.filterTicketsAnd(
75+
username ? ticket.userNameFilter(
76+
data.tickets, username) : data.tickets
77+
, {
78+
'roomName': message.roomName,
79+
'status': 'open'
80+
}),
7681
}),
7782
regexp: /todo ?(\w*)/i,
78-
reply: (message, output) => ticket.showTickets(
79-
output.tickets, ['open'], output.username),
83+
reply: (message, output) => ticket.showTickets(output.tickets),
8084
},
8185
{
82-
action: (data, _message) => data.tickets,
86+
action: (data, message) => ({
87+
'tickets': ticket.filterTicketsOr(
88+
ticket.userNameFilter(data.tickets, message.userName)
89+
, {
90+
status: 'open'
91+
})
92+
}),
8393
regexp: /mine/i,
84-
reply: (message, output) => ticket.showTickets(output, ['open'], message.userName),
94+
reply: (message, output) => ticket.showTickets(output.tickets),
8595
},
8696
{
87-
action: (data, _message) => data.tickets,
97+
action: (data, message) => ({
98+
'tickets': ticket.filterTicketsOr(data.tickets, {
99+
'roomName': message.roomName,
100+
}),
101+
}),
88102
regexp: /history/i,
89-
reply: (message, output) => ticket.showTickets(output, ['open', 'closed']),
103+
reply: (message, output) => ticket.showTickets(output.tickets),
90104
},
91105
{
92106
action: (data, _message, id) => ticket.forgetTicket(data.tickets, id),

test/support_test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,40 @@ function twoTickets() {
5454
}
5555
}
5656

57+
function threeTickets() {
58+
return {
59+
tickets: {
60+
'1': {
61+
assignee: null,
62+
closed: null,
63+
content: 'content',
64+
id: '1',
65+
requester: 'Ricky',
66+
roomName: 'MyRoom',
67+
status: 'open',
68+
},
69+
'2': {
70+
assignee: null,
71+
closed: null,
72+
content: 'content',
73+
id: '2',
74+
requester: 'Dmitry',
75+
roomName: 'MyRoom',
76+
status: 'open',
77+
},
78+
'3': {
79+
assignee: 'Ricky',
80+
closed: null,
81+
content: 'content',
82+
id: '3',
83+
requester: 'Dmitry',
84+
roomName: 'OtherRoom',
85+
status: 'open',
86+
},
87+
lastId: 3,
88+
}
89+
}
90+
}
5791
function emptyData() {
5892
return {
5993
tickets: {
@@ -166,6 +200,13 @@ describe('support', function() {
166200
assert.match(reply, /I don't understand the question/)
167201
})
168202

203+
it('TODO excludes other rooms ticket', function() {
204+
const reply = support.process(threeTickets(), message('todo'))
205+
assert.match(reply, /#1/)
206+
assert.match(reply, /#2/)
207+
assert.notMatch(reply, /#3/)
208+
})
209+
169210
it('inventory', function() {
170211
const data = emptyData()
171212
data.fs = {

0 commit comments

Comments
 (0)