Skip to content

Commit 0f96fc8

Browse files
authored
Merge branch 'develop' into bug/@mui
2 parents 847f031 + 37cfbde commit 0f96fc8

File tree

7 files changed

+49
-21
lines changed

7 files changed

+49
-21
lines changed

.github/dependabot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ updates:
1212
labels:
1313
- "dependencies"
1414
# Specify the target branch for PRs
15-
target-branch: "develop"
15+
target-branch: "develop-postgres"
1616
# Customize commit message prefix
1717
commit-message:
1818
prefix: "chore(deps):"

.github/pull_request_template.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ Thanks for submitting a pull request! Please provide enough information so that
2424

2525
Fixes #<!--Add related issue number here.-->
2626

27-
**Did you add tests for your changes?**
28-
29-
<!--Yes or No. Note: Add unit tests or automation tests for your code.-->
30-
3127
**Snapshots/Videos:**
3228

3329
<!--Add snapshots or videos wherever possible.-->
@@ -45,6 +41,19 @@ Fixes #<!--Add related issue number here.-->
4541

4642
<!-- If this PR introduces a breaking change, please describe the impact and a migration path for existing applications. -->
4743

44+
## Checklist
45+
46+
### CodeRabbit AI Review
47+
- [ ] I have reviewed and addressed all critical issues flagged by CodeRabbit AI
48+
- [ ] I have implemented or provided justification for each non-critical suggestion
49+
- [ ] I have documented my reasoning in the PR comments where CodeRabbit AI suggestions were not implemented
50+
51+
### Test Coverage
52+
- [ ] I have written tests for all new changes/features
53+
- [ ] I have verified that test coverage meets or exceeds 95%
54+
- [ ] I have run the test suite locally and all tests pass
55+
56+
4857
**Other information**
4958

5059
<!--Add extra information about this PR here-->

.github/workflows/pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ jobs:
318318
runs-on: ubuntu-latest
319319
steps:
320320
- name: "Check if base branch is develop"
321-
if: github.event.pull_request.base.ref != 'develop'
321+
if: github.event.pull_request.base.ref != 'develop-postgres'
322322
run: |
323-
echo "PR is not against develop branch. Please refer PR_GUIDELINES.md"
323+
echo "PR is not against develop-postgres branch. Please refer PR_GUIDELINES.md"
324324
exit 1

eslint.config.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import * as graphqlEslint from "@graphql-eslint/eslint-plugin";
1414
const __filename = fileURLToPath(import.meta.url);
1515
const __dirname = path.dirname(__filename);
1616
const compat = new FlatCompat({
17-
baseDirectory: __dirname,
18-
recommendedConfig: js.configs.recommended,
17+
baseDirectory: __dirname,
18+
recommendedConfig: js.configs.recommended
1919
});
2020

2121
export default [
@@ -44,7 +44,9 @@ export default [
4444

4545
languageOptions: {
4646
parser: tsParser,
47-
globals: globals.node,
47+
globals: {
48+
...globals.node,
49+
},
4850
},
4951
rules: {
5052
"no-restricted-imports": [
@@ -142,7 +144,7 @@ export default [
142144
},
143145

144146
languageOptions: {
145-
parser: parser,
147+
parser: graphqlEslint.parser,
146148
},
147149
},
148150
{

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
black==22.12.0
1+
black==24.3.0
22
pydocstyle==6.3.0
33
pylint==2.15.10
44
pymongo==4.3.3

src/resolvers/Mutation/sendMembershipRequest.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ export const sendMembershipRequest: MutationResolvers["sendMembershipRequest"] =
7878

7979
// Checks if the user is blocked
8080
const user = await User.findById(context.userId).lean();
81+
8182
if (
82-
user !== null &&
83+
user != null &&
8384
organization.blockedUsers.some((blockedUser) =>
8485
new mongoose.Types.ObjectId(blockedUser.toString()).equals(user._id),
8586
)
@@ -96,21 +97,38 @@ export const sendMembershipRequest: MutationResolvers["sendMembershipRequest"] =
9697
user: context.userId,
9798
organization: organization._id,
9899
});
99-
100100
if (membershipRequestExists) {
101+
// Check if the request is already in the user's document
102+
if (
103+
user != null &&
104+
!user.membershipRequests.includes(membershipRequestExists._id)
105+
) {
106+
// If it's not in the user's document, add it
107+
await User.findByIdAndUpdate(
108+
context.userId,
109+
{
110+
$push: {
111+
membershipRequests: membershipRequestExists._id,
112+
},
113+
},
114+
{ new: true, runValidators: true },
115+
);
116+
}
117+
101118
throw new errors.ConflictError(
102119
requestContext.translate(MEMBERSHIP_REQUEST_ALREADY_EXISTS.MESSAGE),
103120
MEMBERSHIP_REQUEST_ALREADY_EXISTS.CODE,
104121
MEMBERSHIP_REQUEST_ALREADY_EXISTS.PARAM,
105122
);
106123
}
107124

125+
// Creating Membership Request
108126
const createdMembershipRequest = await MembershipRequest.create({
109127
user: context.userId,
110128
organization: organization._id,
111129
});
112130

113-
// add membership request to organization
131+
// Updating Membership Request in organization
114132
const updatedOrganization = await Organization.findOneAndUpdate(
115133
{
116134
_id: organization._id,
@@ -129,16 +147,15 @@ export const sendMembershipRequest: MutationResolvers["sendMembershipRequest"] =
129147
await cacheOrganizations([updatedOrganization]);
130148
}
131149

132-
// add membership request to user
133-
await User.updateOne(
134-
{
135-
_id: context.userId,
136-
},
150+
// Updating User
151+
await User.findByIdAndUpdate(
152+
context.userId,
137153
{
138154
$push: {
139155
membershipRequests: createdMembershipRequest._id,
140156
},
141157
},
158+
{ new: true, runValidators: true },
142159
);
143160

144161
return createdMembershipRequest.toObject();

tests/resolvers/Query/getVolunteerRanks.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe("resolvers -> Query -> getVolunteerRanks", () => {
7676
},
7777
{},
7878
)) as unknown as VolunteerRank[];
79-
expect(volunteerRanks[0].hoursVolunteered).toEqual(2);
79+
expect(volunteerRanks[0].hoursVolunteered).toEqual(6);
8080
expect(volunteerRanks[0].user._id).toEqual(testUser1?._id);
8181
expect(volunteerRanks[0].rank).toEqual(1);
8282
});

0 commit comments

Comments
 (0)