-
Notifications
You must be signed in to change notification settings - Fork 1
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
As a dev, I want to retrieve data with filtered option. #230
Comments
@Francois-Werbrouck are the functions required for this already present in the database? |
They are on ai-cfia/ailab-datastore#258 under the issue ai-cfia/ailab-datastore#233 |
I'm going to drop the high level function used here : https://github.com/ai-cfia/ailab-datastore/blob/e06e859d119e9a494872fe3e59ddc44b1aff6d37/fertiscan/__init__.py#L606 def search_inspection(
cursor: Cursor,
fertilizer_name: str,
reg_number: str,
lot_number: str,
inspector_name: str,
lower_bound_date: datetime,
upper_bound_date: datetime,
organization_name: str,
organization_address: str,
organization_phone: str,
):
"""
This function search all the verified inspection based on the given parameters
Parameters:
- cursor (Cursor): The cursor object to interact with the database.
- fertilizer_name (str): The name of the fertilizer.
- reg_number (str): The registration number of the fertilizer.
- lot_number (str): The lot number of the fertilizer.
- inspector_name (str): The name of the inspector. (Not used at the moment)
- lower_bound_date (str): The lower bound date of the inspection.
- upper_bound_date (str): The upper bound date of the inspection.
- organization_name (str): The name of the organization.
- organization_address (str): The address of the organization.
- organization_phone (str): The phone number of the organization.
Returns:
- List of inspection tuple.
[
inspection.id,
inspection.verified
inspection.upload_date,
inspection.updated_at,
inspection.inspector_id
inspection.label_info_id,
inspection.container_id,
inspection.folder_id,
inspection.inspection_comment,
inspection.verified_date,
label_info.product_name,
organization_info.id, (main_contact_id)
organization_info.name,
organization_info.phone_number,
organization_info.address,
label_info.is_minimal,
label_info.record_keeping,
registration_number.identifiers, (list of reg numbers)
]
""" |
Description
As a developer, I want to be able to retrieve inspection data from the database with multiple filtering options.
Context
Currently, our backend system lacks the functionality to fetch all inspection records from the database with flexible filtering. The application needs an API endpoint capable of returning filtered inspection data based on various business and technical criteria. This capability is crucial for efficiently managing inspection records, improving data access speed, and serving specific queries related to inspection data.
Problem Statement
The existing backend does not support retrieving inspection records with filtering based on fields such as fertiliser name, registration number, location, inspection dates, inspector name, and organization details (name, address, phone number). This limitation makes it challenging for users to access specific subsets of data, hindering user experience and potentially impacting system performance due to the need to transfer large datasets without filtering server-side.
Acceptance Criteria
Implement a method in the backend that queries the inspection database with support for filtering by:
Fertiliser name
Registration number
Lot number
Location
Inspector name
Organization name
Organization address
Organization phone number
Before date this one is boolean that when activate search before the given date
After dates this one is boolean that when activate search after the given date
If after and before are false search for the specific date.
Ensure the method returns the expected structure as defined in the InspectionData model.
Incorporate unit tests to validate the filtering logic and ensure the method behaves correctly under various conditions.
** Additional Information (Optional) **
Consider implementing pagination alongside filtering to handle potentially large datasets more efficiently. This would further enhance the performance and user-friendliness of the data retrieval process
Here some code for helping understanding the problem:
The text was updated successfully, but these errors were encountered: