massenergize / api

Backend Code for Massenergize Portal. This provides the API to the backend database, and is shared by the various front-end portal projects.
MIT License
5 stars 9 forks source link

feat: add caching for translated data in API requests #1145

Closed abdullai-t closed 3 months ago

abdullai-t commented 3 months ago

Summary / Highlights

This pull request introduces a caching layer to the JsonTranslator utility, enhancing the efficiency of translation API requests. When a translation request is made, the system first checks the database for a cached translation. If a cached translation is found, it is retrieved and used, avoiding the need for an API call to GCT. If no cached translation exists, the request is sent to GCT for translation. Once the translation is received, it is sent to a background function that saves the translation to the database for future use.

Details (Give details about what this PR accomplishes, include any screenshots etc)

Testing Steps (Provide details on how your changes can be tested)

run make test

Requirements (place an x in each [ ])

Transparency (Project board)
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 88.63636% with 5 lines in your changes missing coverage. Please review.

Project coverage is 56.08%. Comparing base (b8aa4a5) to head (7370fd4). Report is 5 commits behind head on main.

Files Patch % Lines
src/_main_/utils/translation/__init__.py 85.71% 5 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1145 +/- ## ========================================== + Coverage 56.05% 56.08% +0.02% ========================================== Files 461 461 Lines 33940 33928 -12 ========================================== + Hits 19025 19027 +2 + Misses 14915 14901 -14 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.