Skip to content

Commit 7f981ff

Browse files
authored
feat: Added api contracts for orphaned tasks and departed users. (#200)
* feat: Added api contracts for orphaned tasks and departed users. * fix: Changed departed to orphaned in tasks file.
1 parent d62809f commit 7f981ff

File tree

2 files changed

+91
-57
lines changed

2 files changed

+91
-57
lines changed

tasks/README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<task_id>,
2727
<task_id>
2828
],
29-
"level": 1 | 2 | 3 | 4 | 5 // optional - can be added only if category exists,
29+
"level": 1 | 2 | 3 | 4 | 5 // optional - can be added only if category exists,
3030
"category": <string> // optional (example: "FRONTEND" | "BACKEND"),
3131
"participants": [
3232
// for group tasks
@@ -57,23 +57,23 @@
5757

5858
## **Requests**
5959

60-
| Route | Description |
61-
| :--------------------------------: | :---------------: |
62-
| [GET /tasks](#get-tasks) | Returns all tasks |
63-
| [GET /tasks/self](#get-tasksself) | Returns all tasks of a user |
64-
| [POST /tasks](#post-tasks) | Creates new task |
65-
| [PATCH /tasks/:id](#patch-tasksid) | Updates tasks |
66-
| [GET /tasks/:id/details](#get-tasksiddetails) | Get details of a particular task|
67-
| [GET /tasks/:username](#get-tasksusername) | Returns all tasks of the user |
68-
| [PATCH /tasks/self/:id](#patch-tasksselfid) | Changes in own task |
60+
| Route | Description |
61+
| :-------------------------------------------: | :------------------------------: |
62+
| [GET /tasks](#get-tasks) | Returns all tasks |
63+
| [GET /tasks/self](#get-tasksself) | Returns all tasks of a user |
64+
| [POST /tasks](#post-tasks) | Creates new task |
65+
| [PATCH /tasks/:id](#patch-tasksid) | Updates tasks |
66+
| [GET /tasks/:id/details](#get-tasksiddetails) | Get details of a particular task |
67+
| [GET /tasks/:username](#get-tasksusername) | Returns all tasks of the user |
68+
| [PATCH /tasks/self/:id](#patch-tasksselfid) | Changes in own task |
6969

7070
## **GET /tasks**
7171

7272
Returns all the tasks
7373

7474
- **Params**
7575
None
76-
- **Query**
76+
- **Query**
7777
- Optional: `dev=[boolean]` (`dev` is passed to get all tasks in the developer mode with features that are flagged)
7878
- Optional: `status=[string]` (`status` is a case insenstive string with one of the following values [AVAILABLE, ASSIGNED, COMPLETED, IN_PROGRESS, BLOCKED, SMOKE_TESTING, NEEDS_REVIEW, IN_REVIEW, APPROVED, MERGED, SANITY_CHECK, REGRESSION_CHECK, RELEASED, VERIFIED, DONE, UNASSIGNED] which represents the status of the task)
7979
- Optional: `assignee=[string]` (`assignee` can be assignee username in case of single assignee or multiple comma separated values in case of multiple assignee)
@@ -82,6 +82,7 @@ Returns all the tasks
8282
- Optional: `size=[integer]` (`size` is the number of tasks requested per page. Range of value is 1-100. Default value is 5)
8383
- Optional: `next=[string]` (`next` is id of the document to get next page of results from that document)
8484
- Optional: `prev=[string]` (`prev` is id of the document to get prev page of results from that document)
85+
- Optional: `orphaned=[boolean]` ( if orphaned is set to true with dev feature flag as true, it will return all the pending tasks which have assigned to users who have departed the discord server. )
8586
- **Body**
8687
None
8788
- **Headers**
@@ -102,10 +103,16 @@ Returns all the tasks
102103
}
103104
```
104105

106+
- **Code:** 204 (for `orphaned=true` when no orphaned tasks exist)
107+
108+
- **Content:** `No Content`
109+
105110
- **Error Response:**
106111
- **Code:** 500
107112
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`
108-
113+
- **Code:** 404 (for `orphaned=true` without `dev=true`)
114+
- **Content:**
115+
`{ 'message': 'Route not found' }`
109116

110117
## **GET /tasks/self**
111118

@@ -124,6 +131,7 @@ Returns all the completed tasks of user if query `completed=true` is passed, els
124131
- **Success Response:**
125132
- **Code:** 200
126133
- **Content:**
134+
127135
```
128136
[
129137
{<task_object>},
@@ -157,6 +165,7 @@ Returns details of a particular task
157165
- **Success Response:**
158166
- **Code:** 200
159167
- **Content:**
168+
160169
```
161170
{
162171
"message":"task returned successfully",
@@ -187,6 +196,7 @@ Returns all tasks of the requested user.
187196
- **Success Response:**
188197
- **Code:** 200
189198
- **Content:**
199+
190200
```
191201
{
192202
message: 'Tasks returned successfully!'
@@ -203,7 +213,6 @@ Returns all tasks of the requested user.
203213
- **Code:** 500
204214
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`
205215

206-
207216
## **POST /tasks**
208217

209218
- **Params**
@@ -265,10 +274,11 @@ Returns all tasks of the requested user.
265274
- **Headers**
266275
Content-Type: application/json
267276

268-
- **Body**
277+
- **Body**
278+
269279
```
270-
{
271-
status: <new-status>
280+
{
281+
status: <new-status>
272282
percentCompleted: <number>
273283
}
274284
```
@@ -278,6 +288,7 @@ Returns all tasks of the requested user.
278288

279289
- **Success Response:**
280290
- **Code**: 200
291+
281292
```
282293
{
283294
message: 'Task updated successfully!'
@@ -292,6 +303,7 @@ Returns all tasks of the requested user.
292303
}
293304
}
294305
```
306+
295307
- **Error Response:**
296308
- **Code:** 401
297309
- **Content:** `{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'User can not be authenticated' }`

users/README.md

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ number and email address.
3737

3838
## **Requests**
3939

40-
| Route | Description |
41-
| :----------------------------------------------------: | :----------------------------------: |
42-
| [GET /users](#get-users) | Returns all users in the system |
43-
| [GET /users/self](#get-usersSelf) | Returns the logged in user's details |
44-
| [GET /users/userId/:userId](#get-usersuseriduserid) | Returns user with given userId |
45-
| [GET /users/:username](#get-usersusername) | Returns user with given username |
46-
| [GET /users/:userId/badges](#get-usersidbadges) | Returns badges assigned to the user |
47-
| [GET /users/search](#get-users-search) | Returns users based on specified filters |
48-
| [POST /users](#post-users) | Creates a new User |
49-
| [PATCH /users/self](#patch-usersself) | Updates data of the User |
50-
| [PATCH /users/:id/temporary/data](#patch-usersidroles) | Updates user roles |
51-
| [PATCH /users](#patch-users) | Archive users if not in discord |
40+
| Route | Description |
41+
| :----------------------------------------------------: | :--------------------------------------: |
42+
| [GET /users](#get-users) | Returns all users in the system |
43+
| [GET /users/self](#get-usersSelf) | Returns the logged in user's details |
44+
| [GET /users/userId/:userId](#get-usersuseriduserid) | Returns user with given userId |
45+
| [GET /users/:username](#get-usersusername) | Returns user with given username |
46+
| [GET /users/:userId/badges](#get-usersidbadges) | Returns badges assigned to the user |
47+
| [GET /users/search](#get-users-search) | Returns users based on specified filters |
48+
| [POST /users](#post-users) | Creates a new User |
49+
| [PATCH /users/self](#patch-usersself) | Updates data of the User |
50+
| [PATCH /users/:id/temporary/data](#patch-usersidroles) | Updates user roles |
51+
| [PATCH /users](#patch-users) | Archive users if not in discord |
5252

5353
## **GET /users**
5454

@@ -64,14 +64,17 @@ Returns all users in the system.
6464
- Optional: `next=[string]` (`next` is the id of the DB document to get the next batch/page of results after that document.)
6565
- Optional: `prev=[string]` (`prev` is the id of the DB document to get the previous batch/page of results before that document.)
6666
- Optional: `query=[string]` (`query` can be used to filter and/or sort users based on their PR and Issue status within a given date range. [Learn more](https://github.com/Real-Dev-Squad/website-backend/wiki/Filter-and-sort-users-based-on-PRs-and-Issues) )
67+
- Optional: `departed=[boolean]` ( if departed is set to true with dev feature flag as true, it will return all the users who have departed the discord server with pending tasks assigned to them. )
6768
- **Body**
6869
None
6970
- **Headers**
7071
Content-Type: application/json
7172
- **Cookie**
7273
rds-session: `<JWT>`
7374
- **Success Response:**
75+
7476
- **Code:** 200
77+
7578
- **Content:**
7679

7780
```
@@ -88,7 +91,9 @@ Returns all users in the system.
8891
```
8992
9093
**If `/users?profile=true`**
94+
9195
- **Code:** 200
96+
9297
- **Content:**
9398
9499
```
@@ -97,10 +102,20 @@ Returns all users in the system.
97102
}
98103
```
99104
105+
**If `/users?departed=true&dev=true`**
106+
107+
- **Code:** 204 (for `departed=true` when no abandoned tasks exist)
108+
109+
- **Content:**
110+
`{}`
111+
100112
- **Error Response:**
101113
- **Code:** 401
102114
- **Content:**
103115
`{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }`
116+
- **Code:** 404 (for `departed=true` without `dev=true`)
117+
- **Content:**
118+
`{ 'message': 'Route not found' }
104119
105120
## **GET /users/self**
106121
@@ -235,6 +250,7 @@ Returns users based on the specified filters.
235250
None
236251
237252
- **Query Parameters:**
253+
238254
- Optional: `levelId=[string]` (Specifies the level ID)
239255
- Optional: `levelName=[string]` (Specifies the level name)
240256
- Optional: `levelValue=[number]` (Specifies the level value)
@@ -252,7 +268,9 @@ Returns users based on the specified filters.
252268
rds-session: `<JWT>`
253269
254270
- **Success Response:**
271+
255272
- **Code:** 200
273+
256274
- **Content:**
257275
258276
```
@@ -270,11 +288,14 @@ Returns users based on the specified filters.
270288
```
271289
272290
- **Error Response:**
291+
273292
- **Code:** 400
293+
274294
- **Content:**
275295
`{ 'statusCode': 400, 'error': 'Bad Request', 'message': 'Filter for item not provided' }`
276296
277297
- **Code:** 401
298+
278299
- **Content:**
279300
`{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }`
280301
@@ -307,12 +328,13 @@ Creates a new User.
307328
`{ 'statusCode': 401, 'error': 'Unauthorized', 'message': 'Unauthenticated User' }`
308329
309330
## **PATCH /users/self(To Be Deprecated)**
310-
> **⚠️ Deprecation Notice**
311-
>
312-
> This endpoint is scheduled for deprecation. A new endpoint will be announced in the future to replace this functionality.
313-
Please prepare to update your integrations accordingly.
314331
315-
Updates data of the User. Doesn't update if user is `(in_discord && !userDetailsIncomplete)`, Except for `disabled_roles` property.
332+
> **⚠️ Deprecation Notice**
333+
>
334+
> This endpoint is scheduled for deprecation. A new endpoint will be announced in the future to replace this functionality.
335+
> Please prepare to update your integrations accordingly.
336+
337+
Updates data of the User. Doesn't update if user is `(in_discord && !userDetailsIncomplete)`, Except for `disabled_roles` property.
316338
317339
- **Params**
318340
None
@@ -396,7 +418,7 @@ Archive users if not in Discord.
396418
397419
```json
398420
{
399-
"action": "nonVerifiedDiscordUsers | archiveUsers"
421+
"action": "nonVerifiedDiscordUsers | archiveUsers"
400422
}
401423
```
402424

@@ -406,27 +428,27 @@ Archive users if not in Discord.
406428

407429
```json
408430
{
409-
"message": "Successfully updated users archived role to true if in_discord role is false | Couldn't find any users currently inactive in Discord but not archived.",
410-
"data": {
411-
"totalUsers": "number",
412-
"totalUsersArchived": "number",
413-
"totalOperationsFailed": "number"
414-
}
431+
"message": "Successfully updated users archived role to true if in_discord role is false | Couldn't find any users currently inactive in Discord but not archived.",
432+
"data": {
433+
"totalUsers": "number",
434+
"totalUsersArchived": "number",
435+
"totalOperationsFailed": "number"
436+
}
415437
}
416438
```
417439

418440
**Addition info if debug query is set to true**
419441

420442
```json
421443
{
422-
"message": "Successfully updated users archived role to true if in_discord role is false | Couldn't find any users currently inactive in Discord but not archived.",
423-
"data": {
424-
"totalUsers": "number",
425-
"totalUsersArchived": "number",
426-
"totalOperationsFailed": "number",
427-
"updatedUserDetails": "array",
428-
"failedUserDetails": "array"
429-
}
444+
"message": "Successfully updated users archived role to true if in_discord role is false | Couldn't find any users currently inactive in Discord but not archived.",
445+
"data": {
446+
"totalUsers": "number",
447+
"totalUsersArchived": "number",
448+
"totalOperationsFailed": "number",
449+
"updatedUserDetails": "array",
450+
"failedUserDetails": "array"
451+
}
430452
}
431453
```
432454

@@ -438,9 +460,9 @@ Archive users if not in Discord.
438460

439461
```json
440462
{
441-
"statusCode": 401,
442-
"error": "Unauthorized",
443-
"message": "Unauthenticated User"
463+
"statusCode": 401,
464+
"error": "Unauthorized",
465+
"message": "Unauthenticated User"
444466
}
445467
```
446468

@@ -450,9 +472,9 @@ Archive users if not in Discord.
450472

451473
```json
452474
{
453-
"statusCode": 400,
454-
"error": "Bad Request",
455-
"message": "Invalid payload"
475+
"statusCode": 400,
476+
"error": "Bad Request",
477+
"message": "Invalid payload"
456478
}
457479
```
458480

@@ -462,8 +484,8 @@ Archive users if not in Discord.
462484

463485
```json
464486
{
465-
"statusCode": 500,
466-
"error": "Internal Server Error",
467-
"message": "An internal server error occurred"
487+
"statusCode": 500,
488+
"error": "Internal Server Error",
489+
"message": "An internal server error occurred"
468490
}
469491
```

0 commit comments

Comments
 (0)