Skip to content

Reduce load on background worker#11651

Merged
SchrodingersGat merged 8 commits intoinventree:masterfrom
SchrodingersGat:de-duplicate-task
Apr 1, 2026
Merged

Reduce load on background worker#11651
SchrodingersGat merged 8 commits intoinventree:masterfrom
SchrodingersGat:de-duplicate-task

Conversation

@SchrodingersGat
Copy link
Copy Markdown
Member

@SchrodingersGat SchrodingersGat commented Apr 1, 2026

This PR introduces two changes to reduce the load on the background worker by removing duplicate entries:

  • Do not save global settings if the value is unchanged
  • Do not queue background tasks if there is already an identical entry

Tasks

  • Add unit test for new de-duplication code

@SchrodingersGat SchrodingersGat added this to the 1.3.0 milestone Apr 1, 2026
@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature refactor labels Apr 1, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 1, 2026

Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit 46db89d
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/69ccad8fb296af00087b2304

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.45%. Comparing base (080edc8) to head (46db89d).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11651      +/-   ##
==========================================
+ Coverage   91.44%   91.45%   +0.01%     
==========================================
  Files         963      963              
  Lines       49798    49836      +38     
==========================================
+ Hits        45536    45576      +40     
+ Misses       4262     4260       -2     
Flag Coverage Δ
backend 89.25% <97.43%> (+0.01%) ⬆️
migrations 41.81% <15.38%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 91.71% <ø> (ø)
Backend General 93.41% <100.00%> (+<0.01%) ⬆️
Frontend ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat SchrodingersGat added the full-run Always do a full QC CI run label Apr 1, 2026
set_global_setting(f'_{task_name}_SUCCESS', datetime.now().isoformat(), None)


def check_existing_task(taskname, group: str, *args, **kwargs) -> Optional[str]:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how does this handle repeat events on the same item?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The default action is to ignore duplicate events, but once the first event is complete, a new one can be added.

Also the offload_task function now has a check_duplicates argument which can be set to False to force a duplicate

@SchrodingersGat SchrodingersGat merged commit c8bcb92 into inventree:master Apr 1, 2026
38 checks passed
@SchrodingersGat SchrodingersGat deleted the de-duplicate-task branch April 1, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This is an suggested enhancement or new feature full-run Always do a full QC CI run refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants