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] Allow Admins to Update Multiple Products in a Single Request. #1179

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

Conversation

Lamido-stack
Copy link
Contributor

[FEAT] Allow Admins to Update Multiple Products in a Single Request.


Description

This pull request introduces a new feature: a batch update functionality for multiple products in a single request. The batch_update endpoint that accepts a list of product updates and processes.

Related Issue (Link to issue ticket)

#1122

Motivation and Context

The motivation for this change was to enable the ability to update multiple products at once, reducing the need for multiple individual update requests. This feature was required for:

  1. Improving efficiency when updating large numbers of products.
  2. Providing users with a clear, detailed response indicating which updates were successful and which ones failed.

How Has This Been Tested?

Testing was performed under the following conditions:

  1. Valid Updates: Multiple products were updated simultaneously. All products were valid and the updates were successful.
  2. Non-Existent Product ID: I tested with a batch of products where one or more products had invalid or non-existent product IDs, ensuring the endpoint handled such cases and returned appropriate error messages.

Tests were conducted using FastAPI's Swagger UI (interactive documentation)

Types of changes

  • 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)

Copy link
Contributor

@joboy-dev joboy-dev left a comment

Choose a reason for hiding this comment

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

Where are your tests??

@Lamido-stack
Copy link
Contributor Author

will add them

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

Comment on lines +247 to +249
product = product_service.fetch_single_by_organisation(
db, org_id, update.product_id, current_user
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of fetching each product individually inside the loop, retrieve all products at once using a single query before entrying the loop for update.

This reduces the number of DB hits and speeds up processing.

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.

3 participants