Skip to content

Use get_or_create_async_task for queuing user storage calc task#3067

Merged
bjester merged 1 commit intolearningequality:sprint-release-2021-03-29from
bjester:once-upon-a-user-storage-task
Apr 5, 2021
Merged

Use get_or_create_async_task for queuing user storage calc task#3067
bjester merged 1 commit intolearningequality:sprint-release-2021-03-29from
bjester:once-upon-a-user-storage-task

Conversation

@bjester
Copy link
Member

@bjester bjester commented Apr 5, 2021

Summary

We observed some slowdowns on hotfixes likely due to the user storage calculation query. We recently added get_or_create_async_task to only queue a task if there isn't one pending. The queuing of the user storage calculation task was using another approach, based off a cache value that may not work as expected (and observed odd behavior locally).

Description of the change(s) you made

Updated the queuing of the user storage calculation task to use get_or_create_asyn_task, and updated one instance that could call the function multiple times with the same user.

Manual verification steps performed

  1. Upload a file
  2. Verify a calculation task was queued and executed
  3. Move the file to trash
  4. Verify a calculation task was queued and executed

Screenshots (if applicable)

Does this introduce any tech-debt items?

We should move contentcuration.utils.user.calculate_user_storage to the User model, since we require a User object for queuing tasks.


Reviewer guidance

How can a reviewer test these changes?

There isn't visibility into this particular task on the front-end, unfortunately.


Contributor's Checklist

Testing:

  • Code is clean and well-commented
  • Contributor has fully tested the PR manually

Reviewer's Checklist

This section is for reviewers to fill out.

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@bjester bjester requested a review from rtibbles April 5, 2021 20:38
@bjester bjester added this to the Sprint 2021-03-29 milestone Apr 5, 2021
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Code changes look right, and the storage calculation was consistently rerun on upload and trash actions.

@codecov
Copy link

codecov bot commented Apr 5, 2021

Codecov Report

Merging #3067 (e7bbb3c) into sprint-release-2021-03-29 (d030297) will increase coverage by 0.01%.
The diff coverage is 72.72%.

Impacted file tree graph

@@                      Coverage Diff                      @@
##           sprint-release-2021-03-29    #3067      +/-   ##
=============================================================
+ Coverage                      85.93%   85.95%   +0.01%     
=============================================================
  Files                            304      304              
  Lines                          16403    16403              
=============================================================
+ Hits                           14096    14099       +3     
+ Misses                          2307     2304       -3     
Impacted Files Coverage Δ
contentcuration/contentcuration/tasks.py 60.34% <ø> (+2.71%) ⬆️
contentcuration/contentcuration/utils/user.py 72.72% <70.00%> (-27.28%) ⬇️
contentcuration/contentcuration/models.py 84.58% <100.00%> (ø)

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 d030297...e7bbb3c. Read the comment docs.

@bjester bjester merged commit ea1e415 into learningequality:sprint-release-2021-03-29 Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants