-
Notifications
You must be signed in to change notification settings - Fork 534
fix:added facility min spec in TagConfigReadSpec #3437
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
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughUserSpec imports were moved from module-level to local scope in facility and organization spec methods; facility serialization now uses a cached model lookup. TagConfigReadSpec gains an optional Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3437 +/- ##
===========================================
+ Coverage 74.46% 74.47% +0.01%
===========================================
Files 449 449
Lines 20699 20700 +1
Branches 2152 2151 -1
===========================================
+ Hits 15413 15416 +3
Misses 4822 4822
+ Partials 464 462 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
care/emr/resources/facility/spec.py (1)
108-114: Consider using the centralizedserialize_audit_usershelper for consistency.While the current implementation works,
OrganizationRetrieveSpec(line 73 incare/emr/resources/organization/spec.py) uses the centralizedcls.serialize_audit_users(mapping, obj)method, which handles bothcreated_byandupdated_byfields. Using the same pattern here would improve consistency and reduce duplication.Additionally, the condition
if obj.created_by:on line 113 checks the related object, potentially triggering a database query. The centralized method checksobj.created_by_idinstead, which is more efficient.🔎 Proposed refactor to use centralized helper
@classmethod def perform_extra_serialization(cls, mapping, obj): - from care.emr.resources.user.spec import UserSpec - mapping["id"] = obj.external_id mapping["read_cover_image_url"] = obj.read_cover_image_url() - if obj.created_by: - mapping["created_by"] = model_from_cache(UserSpec, id=obj.created_by_id) + cls.serialize_audit_users(mapping, obj) mapping["facility_type"] = REVERSE_FACILITY_TYPES[obj.facility_type] if obj.geo_organization: mapping["geo_organization"] = OrganizationReadSpec.serialize(Note: If
FacilityReadSpecintentionally excludesupdated_by, you'll need to add that field to the spec definition as well (similar to howcreated_byis defined on line 104).
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
care/emr/resources/facility/spec.pycare/emr/resources/organization/spec.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (.cursorrules)
**/*.py: Prioritize readability and maintainability; follow Django's coding style guide (PEP 8 compliance).
Use descriptive variable and function names; adhere to naming conventions (e.g., lowercase with underscores for functions and variables).
Files:
care/emr/resources/facility/spec.pycare/emr/resources/organization/spec.py
🧠 Learnings (2)
📓 Common learnings
Learnt from: DraKen0009
Repo: ohcnetwork/care PR: 2620
File: care/facility/models/facility.py:306-311
Timestamp: 2024-11-28T06:16:31.373Z
Learning: In the 'care' project, moving imports of models like `Asset`, `AssetLocation`, `FacilityDefaultAssetLocation`, and `PatientSample` to the module level in `care/facility/models/facility.py` causes circular imports. Therefore, it's acceptable to keep these imports inside the `delete` method of the `Facility` class.
📚 Learning: 2024-11-28T06:16:31.373Z
Learnt from: DraKen0009
Repo: ohcnetwork/care PR: 2620
File: care/facility/models/facility.py:306-311
Timestamp: 2024-11-28T06:16:31.373Z
Learning: In the 'care' project, moving imports of models like `Asset`, `AssetLocation`, `FacilityDefaultAssetLocation`, and `PatientSample` to the module level in `care/facility/models/facility.py` causes circular imports. Therefore, it's acceptable to keep these imports inside the `delete` method of the `Facility` class.
Applied to files:
care/emr/resources/facility/spec.py
🧬 Code graph analysis (2)
care/emr/resources/facility/spec.py (3)
care/emr/resources/base.py (3)
EMRResource(13-168)cacheable(279-305)model_from_cache(232-275)care/emr/resources/user/spec.py (1)
UserSpec(124-138)care/facility/models/facility.py (1)
read_cover_image_url(221-226)
care/emr/resources/organization/spec.py (1)
care/emr/resources/base.py (1)
serialize_audit_users(162-168)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test / Test
🔇 Additional comments (3)
care/emr/resources/facility/spec.py (2)
10-10: LGTM: Import addition supports caching.The
model_from_cacheimport is correctly added to support the new cached serialization pattern.
109-109: Local import correctly addresses circular dependency.Moving the
UserSpecimport to method scope is the appropriate pattern for avoiding circular imports in this codebase.Based on learnings, circular import prevention through local imports is an accepted practice in this project.
care/emr/resources/organization/spec.py (1)
73-73: Excellent refactor: centralized audit serialization.This change correctly addresses the previous review feedback and uses the centralized
serialize_audit_usershelper method. This approach is more maintainable and follows the DRY principle.As per past review comments, this is the recommended pattern for handling audit fields.
Proposed Changes
Merge Checklist
/docsOnly PR's with test cases included and passing lint and test pipelines will be reviewed
@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.