Skip to content

256764: Implement unique field management for households and individu…#356

Open
arsen-vs wants to merge 8 commits into
developfrom
feature/256764-Unique-per-programme-fields
Open

256764: Implement unique field management for households and individu…#356
arsen-vs wants to merge 8 commits into
developfrom
feature/256764-Unique-per-programme-fields

Conversation

@arsen-vs
Copy link
Copy Markdown
Contributor

@arsen-vs arsen-vs commented Apr 1, 2026

…als in program

  • Added functionality to set and manage unique fields for Household and Individual models within the Program class.
  • Introduced methods to save and retrieve unique field values, ensuring that archived values are properly handled during validation.
  • Enhanced the admin interface to allow users to set unique fields for both Household and Individual models.
  • Updated validation logic to check for uniqueness against both current and archived values, improving data integrity.
  • Added tests to verify the correct behavior of unique field management and validation processes.

AB#256764

@arsen-vs arsen-vs marked this pull request as draft April 22, 2026 08:20
@arsen-vs arsen-vs force-pushed the feature/256764-Unique-per-programme-fields branch 2 times, most recently from 431e8bc to 821b7a3 Compare April 23, 2026 08:32
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 96.31336% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.95%. Comparing base (3bd0ad1) to head (8b26d8e).

Files with missing lines Patch % Lines
...untry_workspace/contrib/hope/push/orchestration.py 75.00% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #356      +/-   ##
===========================================
+ Coverage    96.93%   96.95%   +0.01%     
===========================================
  Files          237      237              
  Lines         9798    10007     +209     
  Branches      1092     1124      +32     
===========================================
+ Hits          9498     9702     +204     
- Misses         143      148       +5     
  Partials       157      157              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arsen-vs arsen-vs force-pushed the feature/256764-Unique-per-programme-fields branch from 8bc4202 to 3af6885 Compare May 1, 2026 08:38
@domdinicola
Copy link
Copy Markdown
Contributor

@arsen-vs to resolve conflicts and reimplement

Arsen P added 7 commits June 5, 2026 10:11
…als in program

- Added functionality to set and manage unique fields for Household and Individual models within the Program class.
- Introduced methods to save and retrieve unique field values, ensuring that archived values are properly handled during validation.
- Enhanced the admin interface to allow users to set unique fields for both Household and Individual models.
- Updated validation logic to check for uniqueness against both current and archived values, improving data integrity.
- Added tests to verify the correct behavior of unique field management and validation processes.
- Updated the `has_any_data` method in the Program model to check for associated Batch objects instead of households or individuals.
- Added tests to verify the behavior of `has_any_data` for both saved and unsaved Program instances.
- Introduced additional tests for managing unique fields, ensuring proper handling of unique values and their removal in the Program model.
- Improved test coverage for unique field management methods, confirming expected behavior when unique fields are absent.
- Updated the `has_any_data` method in the Program model to filter Batch objects using `program_id` for improved accuracy.
- Added a new test for `has_any_data` to verify behavior with proxy instances of the Program model.
- Introduced a test for the `archive_removed_unique_values` function to ensure proper handling of unique values during data archiving.
- Enhanced existing tests for validation of unique fields in households, confirming that duplicates are correctly marked as invalid.
…rage

- Refactored the `archive_removed_unique_values` function to better handle unique field values for both households and individuals, ensuring correct persistence during data archiving.
- Updated tests to cover various scenarios for archiving unique values, including cases with no records and configurations.
- Improved the integration of the `selection_owner_for_rdp` function to streamline data retrieval for archiving processes.
… processes

- Added tests to ensure proper handling of unique values, including scenarios for skipping empty values and handling non-list types.
- Improved validation logic for unique fields in both the Program model and workspace actions, ensuring accurate error handling and state management.
- Introduced new test cases for the orchestration of unique values, enhancing overall test coverage and reliability.
@arsen-vs arsen-vs force-pushed the feature/256764-Unique-per-programme-fields branch from 3af6885 to 065c149 Compare June 5, 2026 07:16
…for unique duplicates

- Introduced a dictionary to track household members by their primary keys during validation, improving the handling of unique member validation across households.
- Added a new test case to ensure that households with members having duplicate unique fields are correctly marked as invalid, enhancing overall test coverage for validation scenarios.
@arsen-vs arsen-vs marked this pull request as ready for review June 5, 2026 07:41
def has_any_data(self) -> bool:
if not self.pk:
return False
from country_workspace.models import Batch
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not in the beginning of module?

return normalized or None


def _append_unique_error(obj: Model, field_name: str, message: str) -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Each call to _append_unique_error issues an individual UPDATE query to db. Can we use bulk_update instead?

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