care icon indicating copy to clipboard operation
care copied to clipboard

Fixed: Added in_use field to track used bed

Open aeswibon opened this issue 2 years ago • 6 comments

Updates

  • [x] Fixes #936
  • [x] Added in_use field to Bed model to track used bed
  • [x] Added migration function to update in_use field for previous bed models
  • [x] Updated serializer to update in_use field during bed update

aeswibon avatar Jul 23 '22 03:07 aeswibon

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Jul 23 '22 03:07 sonarqubecloud[bot]

Codecov Report

Merging #939 (88f3109) into master (9730efd) will decrease coverage by 1.43%. The diff coverage is 22.72%.

@@            Coverage Diff             @@
##           master     #939      +/-   ##
==========================================
- Coverage   54.23%   52.80%   -1.44%     
==========================================
  Files         181      181              
  Lines        8826     8855      +29     
==========================================
- Hits         4787     4676     -111     
- Misses       4039     4179     +140     
Impacted Files Coverage Δ
care/facility/api/serializers/bed.py 39.83% <6.25%> (-0.88%) :arrow_down:
care/facility/models/bed.py 86.66% <66.66%> (ø)
...e/utils/serializer/phonenumber_ispossible_field.py 50.00% <0.00%> (-43.75%) :arrow_down:
config/serializers.py 36.84% <0.00%> (-31.58%) :arrow_down:
care/audit_log/middleware.py 47.36% <0.00%> (-22.81%) :arrow_down:
care/users/models.py 73.94% <0.00%> (-16.20%) :arrow_down:
care/facility/models/mixins/permissions/base.py 45.00% <0.00%> (-15.00%) :arrow_down:
care/users/api/viewsets/users.py 43.50% <0.00%> (-12.34%) :arrow_down:
care/facility/api/viewsets/facility.py 58.10% <0.00%> (-12.17%) :arrow_down:
care/users/api/serializers/user.py 56.77% <0.00%> (-9.33%) :arrow_down:
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9730efd...88f3109. Read the comment docs.

codecov-commenter avatar Jul 23 '22 03:07 codecov-commenter

do we need an in_use attribute ? end_date == None serves the same purpose right?

vigneshhari avatar Jul 26 '22 14:07 vigneshhari

@vigneshhari There is an issue coronasafe/care_fe#3216. To fix this issue, I have added in_use field in Bed Model

aeswibon avatar Jul 26 '22 16:07 aeswibon

@cp-Coder you can use the end_date is null to check if a bed is in use.

vigneshhari avatar Jul 27 '22 03:07 vigneshhari

@vigneshhari end_date is present in the ConsultationBed model. In the issue, the user should be able to see only those beds (in the list present in the switch bed form) which are not in use. If the in_use field is not present, then I have to query every bed of that facility in the Bed model(for the list) and in the ConsultationBed model too (to check whether it is still in use or not). This will increase the no of queries to the database.

aeswibon avatar Jul 27 '22 14:07 aeswibon