Skip to content

Commit a8d1b87

Browse files
committed
update docs and fix bug on feedback count
1 parent a1a352f commit a8d1b87

File tree

2 files changed

+132
-31
lines changed

2 files changed

+132
-31
lines changed

backend/handlers/feedbacks.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,15 @@ function CreateFeedbackHandler (db) {
8686
feedbacks = feedbacks.filter((feedback) => {
8787
return feedback.apiKey === user.apiKey
8888
})
89-
const total = feedbacks.length
9089

9190
if (type) {
9291
feedbacks = feedbacks.filter((feedback) => {
9392
return feedback.type === String(type).toUpperCase()
9493
})
9594
}
9695

96+
const total = feedbacks.length
97+
9798
if (limit > 10) {
9899
limit = 5
99100
}
@@ -111,6 +112,7 @@ function CreateFeedbackHandler (db) {
111112
}
112113

113114
async function getSummary (ctx) {
115+
const { type } = ctx.query
114116
let [
115117
user,
116118
feedbacks
@@ -129,6 +131,12 @@ function CreateFeedbackHandler (db) {
129131
return feedback.apiKey === user.apiKey
130132
})
131133

134+
if (type) {
135+
feedbacks = feedbacks.filter((feedback) => {
136+
return feedback.type === String(type).toUpperCase()
137+
})
138+
}
139+
132140
let all = 0
133141
let issue = 0
134142
let idea = 0

backend/vuejs_brasil_feedbacker.json

Lines changed: 123 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info": {
3-
"_postman_id": "251372f2-e473-491b-b440-4feb3deff2ab",
3+
"_postman_id": "bd1ee685-5d10-4e07-941a-39d1954ba426",
44
"name": "Vue.js Brasil - Feedbacker",
55
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
66
},
@@ -20,7 +20,7 @@
2020
}
2121
],
2222
"url": {
23-
"raw": "http://localhost:3000/",
23+
"raw": "http://localhost:3000/?",
2424
"protocol": "http",
2525
"host": [
2626
"localhost"
@@ -40,7 +40,8 @@
4040
},
4141
"response": []
4242
}
43-
]
43+
],
44+
"protocolProfileBehavior": {}
4445
},
4546
{
4647
"name": "Apikey",
@@ -71,7 +72,8 @@
7172
},
7273
"response": []
7374
}
74-
]
75+
],
76+
"protocolProfileBehavior": {}
7577
},
7678
{
7779
"name": "Auth",
@@ -80,13 +82,7 @@
8082
"name": "Fazer login",
8183
"request": {
8284
"method": "POST",
83-
"header": [
84-
{
85-
"key": "Authorization",
86-
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImVhYjc1OWY4LWYyMzgtNGZmOS1hZTkxLWVlMTU1ODk4MjMyOSIsImVtYWlsIjoiaWd1aW5AaWd1aW4ubWUiLCJuYW1lIjoiSWdvciBIYWxmZWxkIiwiaWF0IjoxNjA4NTA2ODAwfQ.AXBHWYY1hioeBXQfhxpI9uBGDH3shKqGgWE2JuTOsh4",
87-
"type": "text"
88-
}
89-
],
85+
"header": [],
9086
"body": {
9187
"mode": "raw",
9288
"raw": "{\n \"email\": \"[email protected]\",\n \"password\": \"1234\"\n}",
@@ -97,7 +93,7 @@
9793
}
9894
},
9995
"url": {
100-
"raw": "http://localhost:3000/auth/login",
96+
"raw": "http://localhost:3000/auth/login?",
10197
"protocol": "http",
10298
"host": [
10399
"localhost"
@@ -156,7 +152,8 @@
156152
},
157153
"response": []
158154
}
159-
]
155+
],
156+
"protocolProfileBehavior": {}
160157
},
161158
{
162159
"name": "Users",
@@ -221,11 +218,50 @@
221218
},
222219
"response": []
223220
}
224-
]
221+
],
222+
"protocolProfileBehavior": {}
225223
},
226224
{
227225
"name": "Feedbacks",
228226
"item": [
227+
{
228+
"name": "Pegar índice de feedbacks",
229+
"protocolProfileBehavior": {
230+
"disableBodyPruning": true
231+
},
232+
"request": {
233+
"method": "GET",
234+
"header": [
235+
{
236+
"key": "Authorization",
237+
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImVhYjc1OWY4LWYyMzgtNGZmOS1hZTkxLWVlMTU1ODk4MjMyOSIsImVtYWlsIjoiaWdvckBpZ29yLm1lIiwibmFtZSI6Iklnb3IgSGFsZmVsZCIsImlhdCI6MTYxMDQyNjg4OH0.88S5YLssZhC_TgotUZFDlcw5Cc3xlQTB0mqsQcQu1dY",
238+
"type": "text"
239+
}
240+
],
241+
"body": {
242+
"mode": "raw",
243+
"raw": "{\n \"type\": \"ISSUE\",\n \"text\": \"Tem um problema aqui\",\n \"fingerprint\": \"10wdjas0da93r0jf\",\n \"device\": \"Chrome 34, Mac OS\",\n \"page\": \"https://feedbacker.com.br/ajuda\"\n}",
244+
"options": {
245+
"raw": {
246+
"language": "json"
247+
}
248+
}
249+
},
250+
"url": {
251+
"raw": "http://localhost:3000/feedbacks/summary",
252+
"protocol": "http",
253+
"host": [
254+
"localhost"
255+
],
256+
"port": "3000",
257+
"path": [
258+
"feedbacks",
259+
"summary"
260+
]
261+
}
262+
},
263+
"response": []
264+
},
229265
{
230266
"name": "Pegar todos os feedbacks",
231267
"request": {
@@ -252,38 +288,93 @@
252288
"response": []
253289
},
254290
{
255-
"name": "Pegar índice de feedbacks",
256-
"protocolProfileBehavior": {
257-
"disableBodyPruning": true
291+
"name": "Pegar todos os feedbacks do tipo IDEA",
292+
"request": {
293+
"method": "GET",
294+
"header": [
295+
{
296+
"key": "Authorization",
297+
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImVhYjc1OWY4LWYyMzgtNGZmOS1hZTkxLWVlMTU1ODk4MjMyOSIsImVtYWlsIjoiaWdvckBpZ29yLm1lIiwibmFtZSI6Iklnb3IgSGFsZmVsZCIsImlhdCI6MTYxMDc0MzgyNn0.2R-hm8yCSAtpcvniI1R9CNF_ZzguRaMZoU2pTrwijds",
298+
"type": "text"
299+
}
300+
],
301+
"url": {
302+
"raw": "http://localhost:3000/feedbacks?type=idea",
303+
"protocol": "http",
304+
"host": [
305+
"localhost"
306+
],
307+
"port": "3000",
308+
"path": [
309+
"feedbacks"
310+
],
311+
"query": [
312+
{
313+
"key": "type",
314+
"value": "idea"
315+
}
316+
]
317+
}
258318
},
319+
"response": []
320+
},
321+
{
322+
"name": "Pegar todos os feedbacks do tipo ISSUE",
259323
"request": {
260324
"method": "GET",
261325
"header": [
262326
{
263327
"key": "Authorization",
264-
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImVhYjc1OWY4LWYyMzgtNGZmOS1hZTkxLWVlMTU1ODk4MjMyOSIsImVtYWlsIjoiaWdvckBpZ29yLm1lIiwibmFtZSI6Iklnb3IgSGFsZmVsZCIsImlhdCI6MTYxMDQyNjg4OH0.88S5YLssZhC_TgotUZFDlcw5Cc3xlQTB0mqsQcQu1dY",
328+
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImVhYjc1OWY4LWYyMzgtNGZmOS1hZTkxLWVlMTU1ODk4MjMyOSIsImVtYWlsIjoiaWdvckBpZ29yLm1lIiwibmFtZSI6Iklnb3IgSGFsZmVsZCIsImlhdCI6MTYxMDc0MzgyNn0.2R-hm8yCSAtpcvniI1R9CNF_ZzguRaMZoU2pTrwijds",
265329
"type": "text"
266330
}
267331
],
268-
"body": {
269-
"mode": "raw",
270-
"raw": "{\n \"type\": \"ISSUE\",\n \"text\": \"Tem um problema aqui\",\n \"fingerprint\": \"10wdjas0da93r0jf\",\n \"device\": \"Chrome 34, Mac OS\",\n \"page\": \"https://feedbacker.com.br/ajuda\"\n}",
271-
"options": {
272-
"raw": {
273-
"language": "json"
332+
"url": {
333+
"raw": "http://localhost:3000/feedbacks?type=issue",
334+
"protocol": "http",
335+
"host": [
336+
"localhost"
337+
],
338+
"port": "3000",
339+
"path": [
340+
"feedbacks"
341+
],
342+
"query": [
343+
{
344+
"key": "type",
345+
"value": "issue"
274346
}
347+
]
348+
}
349+
},
350+
"response": []
351+
},
352+
{
353+
"name": "Pegar todos os feedbacks do tipo OTHER",
354+
"request": {
355+
"method": "GET",
356+
"header": [
357+
{
358+
"key": "Authorization",
359+
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImVhYjc1OWY4LWYyMzgtNGZmOS1hZTkxLWVlMTU1ODk4MjMyOSIsImVtYWlsIjoiaWdvckBpZ29yLm1lIiwibmFtZSI6Iklnb3IgSGFsZmVsZCIsImlhdCI6MTYxMDc0MzgyNn0.2R-hm8yCSAtpcvniI1R9CNF_ZzguRaMZoU2pTrwijds",
360+
"type": "text"
275361
}
276-
},
362+
],
277363
"url": {
278-
"raw": "http://localhost:3000/feedbacks/summary",
364+
"raw": "http://localhost:3000/feedbacks?type=other",
279365
"protocol": "http",
280366
"host": [
281367
"localhost"
282368
],
283369
"port": "3000",
284370
"path": [
285-
"feedbacks",
286-
"summary"
371+
"feedbacks"
372+
],
373+
"query": [
374+
{
375+
"key": "type",
376+
"value": "other"
377+
}
287378
]
288379
}
289380
},
@@ -391,7 +482,9 @@
391482
},
392483
"response": []
393484
}
394-
]
485+
],
486+
"protocolProfileBehavior": {}
395487
}
396-
]
488+
],
489+
"protocolProfileBehavior": {}
397490
}

0 commit comments

Comments
 (0)