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

Improvement: Optimize Fetch All Roles API (#164) #1176

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

baydre
Copy link

@baydre baydre commented Mar 1, 2025

Description

This PR improves the /api/v1/organisations endpoint by optimizing the get_roles_for_organisation function.
Changes include:

  • Remove unnecessary tuple creation and improve query efficiency.
  • Enhanced error handling, ensuring a structured response for failures.
  • Maintaining response format consistency as per project requirements.

Related Issue (Link to issue ticket)

​​Closes #164

Motivation and Context

The improvement ensures:

  • Faster query execution by eliminating unnecessary tuple creation.
  • Better error handling, returning meaningful error messages instead of generic failures.
  • Compliance with the standard API response format.

This improves overall system performance and maintainability.​

How Has This Been Tested?

  • Unit Tests:

    • Tested successful retrieval of all roles (200 OK).
    • Simulated a database error to test server error handling (500 Internal Server Error).
  • Manual Testing:

    • Used Postman and curl to verify API responses.
  • Environment:

    • OS: Ubuntu 20.04
    • Python: 3.10
    • Database: PostgreSQL

Screenshots (if appropriate - Postman, etc):


Screenshot from 2025-03-01 01-07-19

Screenshot from 2025-03-01 01-19-44

Types of changes

  • Improvement Feature (enhances an existing feature)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Notes for Reviewers

  • Please verify the performance improvement in the updated query execution.
  • Check error handling updates to confirm structured responses.

🚀 Looking forward to feedback! 😃

Copy link
Contributor

@samuelogboye samuelogboye left a comment

Choose a reason for hiding this comment

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

LGTM.

But hope this is not your grading PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] API Endpoint to Fetch all Roles within an Organisation.
2 participants