Git ResultUpdate is a good point to run the watched queries, because
maintainers fiels is populated here.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
mods/maintainer.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/mods/maintainer.py b/mods/maintainer.py
index 9f6f347..a92995f 100644
--- a/mods/maintainer.py
+++ b/mods/maintainer.py
@@ -14,12 +14,17 @@ from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest
from django.urls import reverse
from mod import PatchewModule
from api.models import Message, Queue, WatchedQuery
+from api.search import SearchEngine
+from event import register_handler
class MaintainerModule(PatchewModule):
""" Project maintainer related tasks """
name = "maintainer"
+ def __init__(self):
+ register_handler("ResultUpdate", self.on_result_update)
+
def _add_to_queue(self, user, m, queue):
for x in [m] + list(m.get_patches()):
q, created = Queue.objects.get_or_create(user=user, message=x, name=queue)
@@ -33,6 +38,20 @@ class MaintainerModule(PatchewModule):
emit_event("MessageDropping", message=q.message, queue=q)
q.delete()
+ def _update_watch_queue(self, series):
+ se = SearchEngine()
+ for wq in WatchedQuery.objects.all():
+ if se.query_test_message(wq.query, series):
+ self._add_to_queue(wq.user, series, "watched")
+
+ def on_result_update(self, evt, obj, old_status, result):
+ if not isinstance(obj, Message):
+ return
+ if result == obj.git_result and result.status != result.PENDING:
+ # By the time of git result update we should have calculated
+ # maintainers so redo the watched queue
+ self._update_watch_queue(obj)
+
def _update_review_state(self, request, message_id, accept):
if not request.user.is_authenticated:
return HttpResponseForbidden()
--
2.17.2
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel