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

Added AssetPublicQRViewSet to handle QR code based asset retrieval #1625

Merged
merged 7 commits into from
Sep 26, 2023

Conversation

Ashesh3
Copy link
Member

@Ashesh3 Ashesh3 commented Sep 19, 2023

This PR introduces a new viewset, AssetPublicQRViewSet, which allows the retrieval of assets using their QR code identifiers. The viewset checks if the provided identifier is a UUID or the primary key of the asset. If the identifier is not found in the cache, the asset is retrieved from the database, serialized, and stored in the cache for future requests. This update also includes the registration of the new viewset in the API router under the public endpoints.

Required for: ohcnetwork/10bedicu#82

@coronasafe/care-backend-maintainers @coronasafe/care-backend-admins

@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.10% 🎉

Comparison is base (e2cab0d) 59.08% compared to head (39584f0) 59.19%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    coronasafe/care_fe#1625      +/-   ##
==========================================
+ Coverage   59.08%   59.19%   +0.10%     
==========================================
  Files         205      205              
  Lines       11145    11175      +30     
  Branches     1587     1591       +4     
==========================================
+ Hits         6585     6615      +30     
  Misses       4360     4360              
  Partials      200      200              
Files Changed Coverage Δ
care/facility/api/viewsets/asset.py 73.27% <100.00%> (+3.69%) ⬆️

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

@sainak
Copy link
Member

sainak commented Sep 19, 2023

@Ashesh3 add tests for the retrieve method

Copy link
Member

@sainak sainak left a comment

Choose a reason for hiding this comment

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

needs test

@Ashesh3
Copy link
Member Author

Ashesh3 commented Sep 19, 2023

needs test

Added

@Ashesh3 Ashesh3 requested a review from sainak September 19, 2023 16:25
Copy link
Member

@sainak sainak left a comment

Choose a reason for hiding this comment

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

LGTM

care/facility/api/viewsets/asset.py Outdated Show resolved Hide resolved
@vigneshhari
Copy link
Member

You also need to create a signal to delete the cache when an asset updates, need tests for that edge as well.

@Ashesh3
Copy link
Member Author

Ashesh3 commented Sep 19, 2023

You also need to create a signal to delete the cache when an asset updates, need tests for that edge as well.

@vigneshhari added, could you review?

@vigneshhari vigneshhari merged commit 4106fe6 into master Sep 26, 2023
7 checks passed
@vigneshhari vigneshhari deleted the public-asset-qr branch September 26, 2023 19:56
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.

4 participants