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

Update QuestionService Endpoints and Documentation #33

Merged
merged 20 commits into from
Sep 25, 2024

Conversation

KhoonSun47
Copy link

  1. Documentation:
  • Updated README.md with information on the new and updated endpoints.
  • Added detailed descriptions and examples for the add, update, delete and get endpoints.
  1. Endpoints:
  • Added Endpoints for get, update, add and delete.
  1. Database:
  • Added a script for user creation during the initial setup of the database.

KhoonSun47 and others added 12 commits September 15, 2024 22:58
- questionController.ts: Implemented new get endpoint for retrieving
questions.
- questionModel.ts: Updated `Difficulty` enum to `Hard` enum.
- questionRoutes.ts: Added new routes for handling get requests.
- helper.ts: Added helper function for improved error handling.
- Update `getQuestions`: Include optional parameters for filtering.
- Update `getQuestionsByParameters`: Add randomisation.
- Add `addQuestion`: New endpoint to add a question.
- Add `updateQuestion`: New Endpoint to update an existing question.
- Add `deleteQuestion`: New Endpoint to delete a question.
- Improved upon the current GET with updated details
- Add new details on ADD, UPDATE and DELETE Questions
- Add response body for success for getQuestionByParameters
- Update case insensitive for topics
- README.md: Added examples for ease of copy and paste
- questionController.ts: Added additional checking for update
- README.md: Update the documentation with new cmd statements
- MongoDB Settings: Add an initialisation script to create user with
required credentials when the MongoDB container is first started.
Copy link

@samuelim01 samuelim01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems rather thorough, should be good after some minor fixes and figuring out autoincrement IDs!

.idea/.gitignore Outdated Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
services/question/README.md Outdated Show resolved Hide resolved
services/question/README.md Outdated Show resolved Hide resolved
services/question/README.md Show resolved Hide resolved

### Parameters:

- `limit` (Optional) - The number of questions to be returned. If not provided, default limit is 1.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I thought we were excluding the limit field from this endpoint?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I included the limit field because it allows us to control the number of questions returned after filtering, which I think is useful for admins. It also enables us to randomly select questions within that limit.

Then for users, the default is set to one random question, so I don't think they will be affected by this.

services/question/src/controllers/questionController.ts Outdated Show resolved Hide resolved
const query: any = {};

if (title) {
query.title = { $regex: `^${title as string}$`, $options: 'i' };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why regex is being used here for exact (case-insensitive) matches? Given that the server would be the one calling the service, don't think this is necessary (and it would result in slower DB queries).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh okay I get what you mean already, I will make the change.


- `title` (Optional) - Filter by question title.
- `description` (Optional) - Filter by question description.
- `topics` (Optional) - Filter by topics associated with the questions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make more sense for them to pass in an array of topics? Or if you prefer the comma separated method, could you specify it in the README?

Copy link
Author

@KhoonSun47 KhoonSun47 Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I understand what you mean. Hm, I think I will just use the comma separated method and I will write the consideration in README.

KhoonSun47 and others added 8 commits September 24, 2024 10:45
- Edit the README based on comments
- Edit the EndPoints functionality based on comments
- README.md: Update details on the functionality of Endpoints
- index.ts: Initialise counter for questionID when start database
- questionController.ts: Update getQuestions and getQuestionsByParameters
to return empty array if not found
- questionController.ts: Add counter for ID when addQuestion
- counterModel.ts & sequence.ts: Add function to initialise and retrieve
counter
…ay2425s1-project-g03 into init-question

* 'init-question' of https://github.com/KhoonSun47/cs3219-ay2425s1-project-g03:
  Update prettier to format html files (CS3219-AY2425S1#34)
  Fix linting
  Add .env to .gitignore
  Add async animations provider
  Change primeflex import from css to scss
  Add PrimeFlex
  Add ng lint fix
  Add PrimeNG
Copy link

@limcaaarl limcaaarl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM all the endpoints are working

@KhoonSun47 KhoonSun47 merged commit a0b9392 into CS3219-AY2425S1:main Sep 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Question Service README Add question service
3 participants