Skip to content

Commit 3b8620d

Browse files
authored
Merge pull request #508 from AppQuality/UN-2273
UN-2273 add reviewerType to GET /campaigns/:cid/bugs response
2 parents bc0de18 + f97a9a5 commit 3b8620d

8 files changed

Lines changed: 152 additions & 45 deletions

File tree

.env.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ SENTRY_ENVIRONMENT=local
5858

5959

6060
CAMPAIGN_CREATION_WEBHOOK=https://webhook.site/11111111-1111-1111-1111-11111111111
61-
STATUS_CHANGE_WEBHOOK=https://webhook.site/11111111-1111-1111-1111-11111111111
61+
STATUS_CHANGE_WEBHOOK=https://webhook.site/11111111-1111-1111-1111-11111111111
62+
63+
AI_REVIEWER_PROFILE_ID=11111

deployment/after-install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ services:
9797
TESTER_LEADER_CPV2_EMAIL: '${TESTER_LEADER_CPV2_EMAIL}'
9898
TASK_MEDIA_BUCKET: '${TASK_MEDIA_BUCKET}'
9999
OPTIMIZED_TASK_MEDIA_BUCKET: '${OPTIMIZED_TASK_MEDIA_BUCKET}'
100+
AI_REVIEWER_PROFILE_ID: '${AI_REVIEWER_PROFILE_ID}'
100101
volumes:
101102
- /var/docker/keys:/app/keys
102103
logging:

src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const config: {
4141
name: string;
4242
email: string;
4343
};
44+
aiReviewer: number;
4445
} = {
4546
port: process.env.PORT || "3000",
4647
apiRoot: false,
@@ -77,6 +78,7 @@ const config: {
7778
name: process.env.TESTER_LEADER_CPV2_NAME || "Unknown",
7879
email: process.env.TESTER_LEADER_CPV2_EMAIL || "Unknown",
7980
},
81+
aiReviewer: Number(process.env.AI_REVIEWER_PROFILE_ID) || 0,
8082
};
8183

8284
if (process.env.SSL_CHAIN && process.env.SSL_PRIVATE) {

src/reference/openapi.yml

Lines changed: 102 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,11 +2985,86 @@ paths:
29852985
size: 0
29862986
start: 0
29872987
total: 0
2988+
reviewer-types:
2989+
value:
2990+
items:
2991+
- created: string
2992+
duplication: father
2993+
id: 1
2994+
internalId: string
2995+
isFavourite: true
2996+
severity:
2997+
id: 0
2998+
name: string
2999+
status:
3000+
id: 0
3001+
name: string
3002+
tags:
3003+
- id: 0
3004+
name: string
3005+
tester:
3006+
id: 0
3007+
title: string
3008+
type:
3009+
id: 0
3010+
name: string
3011+
updated: string
3012+
- created: string
3013+
duplication: father
3014+
id: 2
3015+
internalId: string
3016+
isFavourite: true
3017+
reviewerType: ai
3018+
severity:
3019+
id: 0
3020+
name: string
3021+
status:
3022+
id: 0
3023+
name: string
3024+
tags:
3025+
- id: 0
3026+
name: string
3027+
tester:
3028+
id: 0
3029+
title: string
3030+
type:
3031+
id: 0
3032+
name: string
3033+
updated: string
3034+
- created: string
3035+
duplication: father
3036+
id: 3
3037+
internalId: string
3038+
isFavourite: true
3039+
reviewerType: human
3040+
severity:
3041+
id: 0
3042+
name: string
3043+
status:
3044+
id: 0
3045+
name: string
3046+
tags:
3047+
- id: 0
3048+
name: string
3049+
tester:
3050+
id: 0
3051+
title: string
3052+
type:
3053+
id: 0
3054+
name: string
3055+
updated: string
3056+
limit: 0
3057+
size: 0
3058+
start: 0
3059+
total: 3
29883060
schema:
29893061
allOf:
2990-
- properties:
3062+
- type: object
3063+
properties:
29913064
items:
3065+
type: array
29923066
items:
3067+
type: object
29933068
properties:
29943069
created:
29953070
type: string
@@ -3005,68 +3080,70 @@ paths:
30053080
type: string
30063081
isFavourite:
30073082
type: boolean
3083+
reviewerType:
3084+
type: string
3085+
enum:
3086+
- ai
3087+
- human
30083088
severity:
3089+
type: object
3090+
required:
3091+
- id
3092+
- name
30093093
properties:
30103094
id:
30113095
type: integer
30123096
name:
30133097
type: string
3098+
status:
3099+
type: object
30143100
required:
30153101
- id
30163102
- name
3017-
type: object
3018-
status:
30193103
properties:
30203104
id:
30213105
type: integer
30223106
name:
30233107
type: string
3024-
required:
3025-
- id
3026-
- name
3027-
type: object
30283108
tags:
3109+
type: array
30293110
items:
30303111
$ref: '#/components/schemas/BugTag'
3031-
type: array
30323112
tester:
3113+
type: object
3114+
required:
3115+
- id
30333116
properties:
30343117
id:
30353118
type: integer
3036-
required:
3037-
- id
3038-
type: object
30393119
title:
30403120
type: string
30413121
type:
3122+
type: object
3123+
required:
3124+
- id
3125+
- name
30423126
properties:
30433127
id:
30443128
type: integer
30453129
name:
30463130
type: string
3047-
required:
3048-
- id
3049-
- name
3050-
type: object
30513131
updated:
30523132
type: string
30533133
required:
3134+
- created
3135+
- duplication
30543136
- id
3055-
- title
30563137
- internalId
3057-
- status
3058-
- type
3138+
- isFavourite
30593139
- severity
3140+
- status
30603141
- tester
3061-
- duplication
3062-
- isFavourite
3063-
- created
3142+
- title
3143+
- type
30643144
- updated
3065-
type: object
3066-
type: array
30673145
required:
30683146
- items
3069-
type: object
30703147
- $ref: '#/components/schemas/PaginationData'
30713148
description: OK
30723149
'403':
@@ -6671,13 +6748,7 @@ paths:
66716748
summary: Get Human Resources for a campaign
66726749
tags: []
66736750
parameters:
6674-
- schema:
6675-
type: string
6676-
name: campaign
6677-
in: path
6678-
required: true
66796751
- $ref: '#/components/parameters/campaign'
6680-
description: Updates tokens_usage in campaign and updates the link between cp_id and agreementId
66816752
put:
66826753
summary: Your PUT endpoint
66836754
tags: []
@@ -12841,6 +12912,7 @@ paths:
1284112912
- id: 0
1284212913
name: Name
1284312914
rate: 0
12915+
description: ''
1284412916
'403':
1284512917
$ref: '#/components/responses/Authentication'
1284612918
'404':
@@ -13173,12 +13245,6 @@ paths:
1317313245
schema:
1317413246
type: object
1317513247
properties: {}
13176-
'':
13177-
content:
13178-
application/json:
13179-
schema:
13180-
type: object
13181-
properties: {}
1318213248
security:
1318313249
- JWT: []
1318413250
requestBody:

src/routes/campaigns/campaignId/bugs/_get/index.spec.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import request from "supertest";
55
const yesterday = new Date(new Date().getTime() - 86400000).toISOString();
66
const tomorrow = new Date(new Date().getTime() + 86400000).toISOString();
77

8+
// mock config to set aiReviewer to 100
9+
jest.mock("@src/config", () => ({
10+
__esModule: true,
11+
default: {
12+
...jest.requireActual("@src/config").default,
13+
aiReviewer: 100,
14+
},
15+
}));
16+
817
beforeAll(async () => {
918
await tryber.tables.WpAppqEvdProfile.do().insert({
1019
id: 1,
@@ -70,7 +79,7 @@ beforeAll(async () => {
7079
status_id: 1,
7180
wp_user_id: 1,
7281
profile_id: 1,
73-
reviewer: 1,
82+
reviewer: 100,
7483
last_editor_id: 1,
7584
severity_id: 1,
7685
bug_replicability_id: 1,
@@ -227,4 +236,16 @@ describe("GET /campaigns/campaignId/bugs", () => {
227236
expect(response.body.items[1]).toHaveProperty("tester", { id: 1 });
228237
expect(response.body.items[2]).toHaveProperty("tester", { id: 1 });
229238
});
239+
// Should return a bug list with reviewerType foreach bug
240+
it("Should return a bug list with reviewerType foreach bug", async () => {
241+
const response = await request(app)
242+
.get("/campaigns/1/bugs")
243+
.set("Authorization", "Bearer admin");
244+
expect(response.body).toHaveProperty("items");
245+
246+
expect(response.body.items).toHaveLength(3);
247+
expect(response.body.items[0]).toHaveProperty("reviewerType", "ai");
248+
expect(response.body.items[1]).toHaveProperty("reviewerType", "human");
249+
expect(response.body.items[2]).toHaveProperty("reviewerType", "human");
250+
});
230251
});

src/routes/campaigns/campaignId/bugs/_get/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
import OpenapiError from "@src/features/OpenapiError";
44
import { tryber } from "@src/features/database";
55
import CampaignRoute from "@src/features/routes/CampaignRoute";
6+
import config from "@src/config";
67

78
interface Tag {
89
id: number;
910
name: string;
1011
}
1112

13+
type ReviewerType =
14+
StoplightOperations["get-campaigns-cid-bugs"]["responses"]["200"]["content"]["application/json"]["items"][number]["reviewerType"];
15+
1216
export default class BugsRoute extends CampaignRoute<{
1317
response: StoplightOperations["get-campaigns-cid-bugs"]["responses"]["200"]["content"]["application/json"];
1418
parameters: StoplightOperations["get-campaigns-cid-bugs"]["parameters"]["path"];
@@ -133,6 +137,7 @@ export default class BugsRoute extends CampaignRoute<{
133137
"is_duplicated",
134138
"duplicated_of_id",
135139
"is_favorite",
140+
"reviewer",
136141
tryber.raw("CAST(created AS CHAR) as created"),
137142
tryber.raw("CAST(updated AS CHAR) as updated"),
138143
tryber.ref("message").as("title"),
@@ -197,6 +202,7 @@ export default class BugsRoute extends CampaignRoute<{
197202
id: bug.bug_type_id,
198203
name: bug.type,
199204
},
205+
reviewerType: bug.reviewer === config.aiReviewer ? "ai" : "human",
200206
}));
201207
}
202208

@@ -277,6 +283,7 @@ export default class BugsRoute extends CampaignRoute<{
277283
.toISOString()
278284
.slice(0, 19)
279285
.replace("T", " "),
286+
reviewerType: bug.reviewerType as ReviewerType,
280287
};
281288
});
282289
}

src/routes/media/_post/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import debugMessage from "@src/features/debugMessage";
22
import upload from "@src/features/upload";
33
import { Context } from "openapi-backend";
44
import path from "path";
5-
import fs from "fs";
65
import busboyMapper from "@src/features/busboyMapper";
76

87
/** OPENAPI-ROUTE: post-media */

0 commit comments

Comments
 (0)