This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
forked from isnifer/daily-reporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.js
145 lines (124 loc) · 3.43 KB
/
constants.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
const path = require('path')
const os = require('os')
const PATH_TO_PROFILE = path.resolve(os.homedir(), '.tipsi_profile.json')
const PATH_TO_REPORT = path.resolve(os.homedir(), '.tipsi_report.json')
const TASK_NUMBER_REGEX = /^\[\S*-\d*\]$/
const NEXT_QUESTION = '—'
const REGULAR_TYPES = {
YESTERDAY: '1',
NOW: '2',
TOMORROW: '3',
DISTRACTED: '4',
BLOCK: '5',
TASK_WAS_CHANGED: '6',
EST_CHANGES: '7',
}
const REFINEMENT_TYPES = {
WORK: 'WORK',
DESCRIPTION: 'DESCRIPTION',
EST_DIFF: 'EST_DIFF',
EST_DESCRIPTION: 'EST_DESCRIPTION',
}
const TASK_TYPES = {
DEVELOPMENT: 'DEVELOPMENT',
REVIEW: 'REVIEW',
TEST: 'TEST',
DESIGN: 'DESIGN',
DOCUMENTATION: 'DOCUMENTATION',
CUSTOM: 'CUSTOM',
}
const TEAM_ROLES = {
FRONTEND: 'Frontend Developer',
BACKEND: 'Backend Developer',
QA: 'QA',
DESIGNER: 'Designer',
}
const TEAM_ROLES_ARRAY = [
TEAM_ROLES.FRONTEND,
TEAM_ROLES.BACKEND,
TEAM_ROLES.QA,
TEAM_ROLES.DESIGNER,
]
const moveToTheNextQustion = question => parseInt(question, 10) + 1
const simpleQuestionsReaction = ({ question, response }) => {
if (response !== NEXT_QUESTION) {
// If response is a task number
if (TASK_NUMBER_REGEX.test(response)) {
return REFINEMENT_TYPES.WORK
}
return 'SAME'
}
return moveToTheNextQustion(question)
}
const simpleSummaryQuestionsReaction = ({ question, response }) => {
if (response !== NEXT_QUESTION) {
// If response is a task number
if (TASK_NUMBER_REGEX.test(response)) {
return REFINEMENT_TYPES.DESCRIPTION
}
return 'SAME'
}
return moveToTheNextQustion(question)
}
const estimateChangesQuestionsReaction = ({ response }) => {
if (response !== NEXT_QUESTION) {
return REFINEMENT_TYPES.EST_DIFF
}
return 'DONE'
}
const REGULAR_QUESTIONS = {
[REGULAR_TYPES.YESTERDAY]: {
name: REGULAR_TYPES.YESTERDAY,
message: 'Что Вы делали вчера?',
then: simpleQuestionsReaction,
},
[REGULAR_TYPES.NOW]: {
name: REGULAR_TYPES.NOW,
message: 'Что Вы делаете сейчас?',
then: simpleQuestionsReaction,
},
[REGULAR_TYPES.TOMORROW]: {
name: REGULAR_TYPES.TOMORROW,
message: 'Что Вы будете делать завтра?',
then: simpleQuestionsReaction,
},
[REGULAR_TYPES.DISTRACTED]: {
name: REGULAR_TYPES.DISTRACTED,
message: 'Было отвлечение на задачу',
then: simpleSummaryQuestionsReaction,
},
[REGULAR_TYPES.BLOCK]: {
name: REGULAR_TYPES.BLOCK,
message: 'Меня блокирует',
then: simpleSummaryQuestionsReaction,
},
[REGULAR_TYPES.TASK_WAS_CHANGED]: {
name: REGULAR_TYPES.TASK_WAS_CHANGED,
message: 'В процессе выполнения изменились требования для задачи',
then: simpleSummaryQuestionsReaction,
},
[REGULAR_TYPES.EST_CHANGES]: {
name: REGULAR_TYPES.EST_CHANGES,
message: 'Сменился эстимейт у задачи',
validate: (input) => {
const value = input.trim()
if (value !== NEXT_QUESTION && !TASK_NUMBER_REGEX.test(value)) {
return 'Введите просто номер задачи, например, 1234'
}
return true
},
then: estimateChangesQuestionsReaction,
},
}
module.exports = {
NEXT_QUESTION,
REGULAR_TYPES,
REGULAR_QUESTIONS,
PATH_TO_PROFILE,
PATH_TO_REPORT,
REFINEMENT_TYPES,
TASK_TYPES,
TASK_NUMBER_REGEX,
TEAM_ROLES,
TEAM_ROLES_ARRAY,
}