Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds tasks/users/discord route #173

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
| [GET /tasks/:id/details](#get-tasksiddetails) | Get details of a particular task|
| [GET /tasks/:username](#get-tasksusername) | Returns all tasks of the user |
| [PATCH /tasks/self/:id](#patch-tasksselfid) | Changes in own task |
| [GET /tasks/users/discord](#get-tasksusersdiscord) | Returns discord details of users with active tasks |

## **GET /tasks**

Expand Down Expand Up @@ -301,3 +302,42 @@ Returns all tasks of the requested user.
- **Content:** `{ 'statusCode': 404, 'error': 'Not Found', 'message': 'Task doesn't exist' }`
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`

## **GET /tasks/users/discord**
Returns a list of Discord IDs of users who have not provided progress updates on their tasks.

- **Parameters**: None required.
- **Query Options**:
- `q=[string]`: Optional parameter. This query can include the following values:
- `status=[string]`: Optional. This is a case-sensitive string, accepting values like [missed-updates].
- `date-count=[integer]`: Optional. Specifies the number of days during which users have not provided an update on their task. Default is [3].
- `date=[timestamp]`: Optional. This is a timestamp which will be excluded while calculating missed updates. There is no default value (e.g., [1702122435405]).
- `weekday=[string]`: Optional. Specifies the weekday(s) to be excluded while calculating missed updates (e.g., [sun, mon, tue, wed, thu, fri, sat]).
- `size=[integer]`: Optional. Determines the number of tasks processed to identify the users. The value range is from 1 to 1000.
- `cursor=[string]`: Optional. This is the ID of the document used to retrieve the next page of results.

Example usage: `?size=10&cursor=1xh3Bsd32&q=status:missed-updates -date-count:3 -date:1702122435405 -weekday:sun -weekday:sat`

- **Body**
None
- **Headers**
Content-Type: application/json
- **Success Response:**
- **Code:** 200
- **Content:**
```
{
message: 'Discord details of users fetched successfully',
data: {
usersToAddRole: Array : `List of users who missed update`
tasks: number : `Total tasks processed`
missedUpdatesTasks: number : `Tasks with missed updates`
}
}
```

- **Error Response:**
- **Code:** 400
- **Content:** `{ 'statusCode': 400, 'error': 'Bad request' }`
- **Code:** 500
- **Content:** `{ 'statusCode': 500, 'error': 'Internal Server Error', 'message': 'An internal server error occurred' }`