Skip to content

Conversation

Roffenlund
Copy link
Contributor

Implement a celery task and caching mechanism for rendering markdown to HTML. This removes the CPU overhead caused by rendering the HTML on every request.

  • Add new celery queue
  • Add new redis cache
  • Implement celery task for handling the markdown render
  • Refactor the API views for readme and changelog to use the celery task

@Roffenlund Roffenlund requested a review from MythicManiac May 27, 2025 17:10
@Roffenlund Roffenlund marked this pull request as draft May 27, 2025 17:10
@codecov
Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.07%. Comparing base (9db0ce7) to head (db27a96).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1151      +/-   ##
==========================================
+ Coverage   93.04%   93.07%   +0.03%     
==========================================
  Files         324      326       +2     
  Lines        9701     9743      +42     
  Branches      863      868       +5     
==========================================
+ Hits         9026     9068      +42     
  Misses        554      554              
  Partials      121      121              

☔ View full report in Codecov by Sentry.
📢 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.

Add a new queue intended for running tasks that are related to rendering
markdown to html.

Add a redis cache for caching the html once it is rendered so we do not
need to re-run the rendering task but can fetch it from redis.

Refs. TS-2516
Implement a celery task for rendering the markdown to html.

Refs. TS-2516
Implement a service which implements the caching logic around calling
the celery task with the correct variables. The intention of the service
is to be re-usable with views and make unit testing easier.

Refs. TS-2516
USe the markdown service which is responsible for calling the markdown
task and handling the cache so we do not need to run the markdown logic
in each request, but can fetch the results from cache instead.

Refs. TS-2516
@Roffenlund Roffenlund force-pushed the slow-cyberstorm-api-endpoints branch from 4d3f442 to 8fd0510 Compare May 28, 2025 12:30
@Roffenlund Roffenlund requested a review from MythicManiac May 28, 2025 12:31
@Roffenlund Roffenlund marked this pull request as ready for review May 28, 2025 12:31
Rewrite the polling logic in the service to use the get() function from
celery instead to wait for the result of a task. Raise errors when
expected, the .get() function raises either a TimeoutError or Exception.

No need to pass the statys_key to the celery task anymore due to the
changes made in the service.

Update tests accordingly.

Refs. TS-2516
@Roffenlund Roffenlund force-pushed the slow-cyberstorm-api-endpoints branch from 966e91d to 8c4ed4e Compare May 28, 2025 16:30
@Roffenlund Roffenlund force-pushed the slow-cyberstorm-api-endpoints branch from 8c4ed4e to 6f6c4a9 Compare May 28, 2025 16:32
Remove the check which raises and error if package_version.readme is
None since readme cannot be null in the database.

Refs. TS-2516
@Roffenlund Roffenlund force-pushed the slow-cyberstorm-api-endpoints branch from 6f6c4a9 to db27a96 Compare May 28, 2025 16:47
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.

2 participants