Private
Public Access
Scope backlog re-apply per-feed and always queue it through Celery (T5, S5)
Completes the T5 fix: reapply_rules_for_user_backlog now computes each feed's subscription-tag ids up front and passes them to evaluate_rules_for_article per article, so a feed/tag-scoped rule from a different feed can't fire on this backlog (see the previous commit's rule_in_scope() in apps.rules.engine). Also completes S5's second half: the "Re-apply" view now always dispatches reapply_rules_for_user.delay() instead of calling the backlog function inline from the request — a large backlog or a regex that outruns the new timeout guard no longer risks tying up a web worker. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
91c0b1dd26
commit
fd8eeb605e
3 files changed
+133
-12
No files matched your search
+6
-5
@@ -5,7 +5,7 @@ from django.views.decorators.http import require_POST
|
||||
|
||||
from .forms import FilterRuleForm
|
||||
from .models import FilterRule
|
||||
from .tasks import reapply_rules_for_user_backlog
|
||||
from .tasks import reapply_rules_for_user
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -48,8 +48,9 @@ def delete_rule(request, rule_id):
|
||||
@require_POST
|
||||
def reapply_rule(request, rule_id):
|
||||
rule = get_object_or_404(FilterRule, user=request.user, pk=rule_id)
|
||||
# Run synchronously for immediate feedback, same pattern as add_feed —
|
||||
# a Celery worker isn't required for this to work.
|
||||
count = reapply_rules_for_user_backlog(rule.pk)
|
||||
messages.success(request, f"Re-applied your rules to {count} unread article(s).")
|
||||
# Always queued, never run inline from the request/response cycle —
|
||||
# a large backlog or a pathological regex could otherwise tie up a
|
||||
# web worker for a long time (see apps.rules.tasks).
|
||||
reapply_rules_for_user.delay(rule.pk)
|
||||
messages.success(request, "Re-applying your rules to your unread backlog…")
|
||||
return redirect("rules:rule_list")
|
||||
Reference in new issue
Block a user