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

feat: create expense without any group attached #68

Merged
merged 19 commits into from
Dec 8, 2024
Merged

Conversation

sub1120
Copy link
Contributor

@sub1120 sub1120 commented Nov 30, 2024

In this PR, i have created expense without considering group.

  • User can create expense without associating it with any group.
  • Admin also can create expense on behalf of any user without associating it with any group.

I have a created another Issue to work on expense considering group related scenarios - #66 .

@github-actions github-actions bot added bug Something isn't working enhancement New feature or request database Database schemas, migrations, and configurations config Project configuration files and environment settings tests Test files, test configurations and testing utilities release labels Nov 30, 2024
@sub1120 sub1120 requested review from shivamvijaywargi and removed request for Copilot November 30, 2024 09:29
@sub1120 sub1120 self-assigned this Nov 30, 2024
@sub1120 sub1120 linked an issue Nov 30, 2024 that may be closed by this pull request
Copy link
Contributor

@shivamvijaywargi shivamvijaywargi left a comment

Choose a reason for hiding this comment

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

Good work, please check the mentioned things and we should be good to go.

Copy link
Contributor

@shivamvijaywargi shivamvijaywargi left a comment

Choose a reason for hiding this comment

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

Good work, one or two minor changes required.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 10 changed files in this pull request and generated 2 suggestions.

Files not reviewed (4)
  • src/app.ts: Evaluated as low risk
  • src/db/schemas/expense.model.ts: Evaluated as low risk
  • src/modules/categories/category.routes.ts: Evaluated as low risk
  • src/common/utils/test.util.ts: Evaluated as low risk

@shivamvijaywargi
Copy link
Contributor

@sub1120 Please reduce the cognitive complexity of create expense function as suggested by the code quality check.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 suggestions.

Files not reviewed (2)
  • src/app.ts: Evaluated as low risk
  • src/modules/expenses/expense.routes.ts: Evaluated as low risk
Comments skipped due to low confidence (3)

src/modules/expenses/expense.handlers.ts:63

  • The error message has a grammatical error. It should be 'Category does not belong to user'.
message: "Category does not belongs to user",

src/modules/expenses/expense.handlers.ts:76

  • There is no test coverage for the case where the db.insert operation in createExpenseRepository fails.
expense = await createExpenseRepository(expensePayload);

src/modules/expenses/expense.repository.ts:6

  • [nitpick] The type alias TExpensePayload could be more descriptive. It should be renamed to CreateExpensePayload to better reflect its purpose.
type TExpensePayload = Omit<TInsertExpenseSchema, "id" | "createdAt" | "updatedAt" | "groupId" >;

Choose a reason for hiding this comment

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated no suggestions.

Copy link
Contributor

@shivamvijaywargi shivamvijaywargi left a comment

Choose a reason for hiding this comment

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

A few things got updated, please make those changes accordingly.

@shivamvijaywargi shivamvijaywargi added this to the V1.0 milestone Dec 5, 2024
Copy link
Contributor

@shivamvijaywargi shivamvijaywargi left a comment

Choose a reason for hiding this comment

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

Please update the correct error message

success: z.boolean().default(false),
message: z.string(),
}),
VALIDATION_ERROR_MESSAGE,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not found should not be same as validation error, please check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shivamvijaywargi i updated error message to Not found error(s). Works?

image

And thank you for getting my attention to "Not Found" status, with this i got to know some mistakes in test cases related to 404. I have fixed them as well. 5ae08b5

Copy link
Contributor

Choose a reason for hiding this comment

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

How about "Requested resource not found"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya this is good. I will update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 9 changed files in this pull request and generated no suggestions.

Files not reviewed (3)
  • src/app.ts: Evaluated as low risk
  • src/db/schemas/expense.model.ts: Evaluated as low risk
  • src/modules/categories/category.util.ts: Evaluated as low risk
@shivamvijaywargi
Copy link
Contributor

Please fix the cognitive complexity, best thing would be to refactor your switch case to its own function.

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 10 changed files in this pull request and generated no suggestions.

Files not reviewed (4)
  • src/modules/expenses/expense.routes.ts: Evaluated as low risk
  • src/modules/expenses/expense.test.ts: Evaluated as low risk
  • src/common/utils/constants.ts: Evaluated as low risk
  • src/db/schemas/expense.model.ts: Evaluated as low risk
Comments skipped due to low confidence (1)

src/modules/expenses/expense.handlers.ts:68

  • [nitpick] The error message 'Category does not belong to valid category user' could be more specific. Consider changing it to 'Category does not belong to the user or the specified payer'.
message: "Category does not belong to valid category user",
@sub1120
Copy link
Contributor Author

sub1120 commented Dec 7, 2024

Please fix the cognitive complexity, best thing would be to refactor your switch case to its own function.

@shivamvijaywargi I’ve refactored the code. In my opinion, extracting switch case to its own function would definitely improve the complexity score, though I’m still a bit uncertain about how the function might evolve when we implement updates to the create expense feature for handling splits.

So for now, following our discussion on category validation, I created a separate function to validate category, which has further reduced complexity. Let me know your thoughts!

@sub1120
Copy link
Contributor Author

sub1120 commented Dec 7, 2024

This Node.js CI build is failing because of eslint errors in ISSUE_TEAMPLATES which we recently added, should we add .github/ISSUE_TEMPLATES to eslint ignore?

@shivamvijaywargi
Copy link
Contributor

This Node.js CI build is failing because of eslint errors in ISSUE_TEAMPLATES which we recently added, should we add .github/ISSUE_TEMPLATES to eslint ignore?

Yes, let's add it.

@shivamvijaywargi
Copy link
Contributor

Please ignore the issues template from ESLint and we can ship this.

Copy link

sonarqubecloud bot commented Dec 8, 2024

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 10 changed files in this pull request and generated no suggestions.

Files not reviewed (4)
  • src/db/schemas/expense.model.ts: Evaluated as low risk
  • src/modules/expenses/expense.repository.ts: Evaluated as low risk
  • src/common/utils/constants.ts: Evaluated as low risk
  • src/app.ts: Evaluated as low risk
@sub1120 sub1120 merged commit 458f3e3 into main Dec 8, 2024
7 checks passed
@shivamvijaywargi shivamvijaywargi deleted the feat/expense branch December 8, 2024 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working config Project configuration files and environment settings database Database schemas, migrations, and configurations enhancement New feature or request release tests Test files, test configurations and testing utilities
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[Feat] Create Expense without Group Id
2 participants