Skip to content

Commit

Permalink
Merge pull request #1109 from OneCommunityGlobal/development
Browse files Browse the repository at this point in the history
Backend Release to Main [2.00]
  • Loading branch information
one-community authored Sep 18, 2024
2 parents 9d42d12 + 2e737d6 commit 4320629
Show file tree
Hide file tree
Showing 19 changed files with 1,751 additions and 54 deletions.
16 changes: 16 additions & 0 deletions requirements/informationController/addInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Check mark: ✅
Cross Mark: ❌

# Add Information

> ## Positive case
1. ✅ Returns 201 if adding new information successfullyn and no cache.
2. ✅ Returns if adding new information successfully and hascache.

> ## Negative case
1. ✅ Returns error 500 if if there are no information in the database and any error occurs when finding the infoName.
2. ✅ Returns error 400 if if there are duplicate infoName in the database.
3. ✅ Returns error 400 if if there are issues when saving new informations.
4. ✅ Returns error 400 if if there are errors when saving the new information.

> ## Edge case
13 changes: 13 additions & 0 deletions requirements/informationController/deleteInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Check mark: ✅
Cross Mark: ❌

# Delete Information

> ## Positive case
1. ✅ Returns 200 if deleting informations successfull and no cache.
2. ✅ Returns if deleting informations successfully and has cache.

> ## Negative case
1. ✅ Returns error 400 if if there is any error when finding the information by information id.

> ## Edge case
13 changes: 13 additions & 0 deletions requirements/informationController/getInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Check mark: ✅
Cross Mark: ❌

# Get Information

> ## Positive case
1. ✅ Returns 200 if the informations key exists in NodeCache.
2. ✅ Returns 200 if there are information in the database.

> ## Negative case
1. ✅ Returns error 404 if if there are no information in the database and any error occurs when finding the information.

> ## Edge case
13 changes: 13 additions & 0 deletions requirements/informationController/updateInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Check mark: ✅
Cross Mark: ❌

# Update Information

> ## Positive case
1. ✅ Returns 200 if updating informations successfully when no cache.
2. ✅ Returns if updating informations successfully when hascache.

> ## Negative case
1. ✅ Returns error 400 if if there is any error when finding the information by information id.

> ## Edge case
16 changes: 16 additions & 0 deletions requirements/reasonSchedulingController/deleteReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Check mark: ✅
Cross Mark: ❌

# deleteReason

> ## Positive case
1. ✅ Receives a POST request in the **/api/reason/:userId/** route.
2. ✅ Return 200 if delete reason successfully.

> ## Negative case
1. ✅ Returns 403 when no permission to delete.
2. ✅ Returns 404 when error in finding user Id.
3. ✅ Returns 404 when error in finding reason.
4. ✅ Returns 500 when error in deleting.

> ## Edge case
14 changes: 14 additions & 0 deletions requirements/reasonSchedulingController/getAllReasons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Check mark: ✅
Cross Mark: ❌

# getAllReasons

> ## Positive case
1. ✅ Receives a GET request in the **/api/reason/:userId** route.
2. ✅ Return 200 if get schedule reason successfully.

> ## Negative case
1. ✅ Returns 404 when error in finding user by Id.
2. ✅ Returns 400 when any error in fetching the user

> ## Edge case
15 changes: 15 additions & 0 deletions requirements/reasonSchedulingController/getSingleReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Check mark: ✅
Cross Mark: ❌

# getSingleReason

> ## Positive case
1. ✅ Receives a GET request in the **/api/reason/single/:userId** route.
2. ✅ Return 200 if not found schedule reason and return empty object successfully.
3. ✅ Return 200 if found schedule reason and return reason successfully.

> ## Negative case
1. ✅ Returns 404 when any error in find user by Id
2. ✅ Returns 400 when any error in fetching the user

> ## Edge case
16 changes: 16 additions & 0 deletions requirements/reasonSchedulingController/patchReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Check mark: ✅
Cross Mark: ❌

# patchReason

> ## Positive case
1. ✅ Receives a POST request in the **/api/breason/** route.
2. ✅ Return 200 if updated schedule reason and send blue sqaure email successfully.

> ## Negative case
1. ✅ Returns 400 for not providing reason.
2. ✅ Returns 404 when error in finding user Id.
3. ✅ Returns 404 when not finding provided reason.
4. ✅ Returns 400 when any error in saving.

> ## Edge case
18 changes: 18 additions & 0 deletions requirements/reasonSchedulingController/postReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Check mark: ✅
Cross Mark: ❌

# postReason

> ## Positive case
1. ✅ Receives a POST request in the **/api/reason/** route.
2. ✅ Return 200 if s dchedule reason and send blue sqaure email successfully.

> ## Negative case
1. ✅ Returns 400 for warning to choose Sunday.
2. ✅ Returns 400 for warning to choose a funture date.
3. ✅ Returns 400 for not providing reason.
4. ✅ Returns 404 when error in finding user Id.
5. ✅ Returns 403 when duplicate reason to the date.
6. ✅ Returns 400 when any error in saving.

> ## Edge case
6 changes: 3 additions & 3 deletions src/controllers/informationController.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const mongoose = require('mongoose');
// const mongoose = require('mongoose');
// const userProfile = require('../models/userProfile');
// const hasPermission = require('../utilities/permissions');
const escapeRegex = require('../utilities/escapeRegex');
const cache = require('../utilities/nodeCache')();
const cacheClosure = require('../utilities/nodeCache');

const informationController = function (Information) {
const cache = cacheClosure();
const getInformations = function (req, res) {
// return all informations if cache is available
if (cache.hasCache('informations')) {
res.status(200).send(cache.getCache('informations'));
return;
}

Information.find({}, 'infoName infoContent visibility')
.then((results) => {
// cache results
Expand Down
Loading

0 comments on commit 4320629

Please sign in to comment.