From nobody Mon Sep 16 19:24:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542766202230288.69060315516435; Tue, 20 Nov 2018 18:10:02 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B5FD3AA1E; Wed, 21 Nov 2018 02:10:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58EC85D9CB; Wed, 21 Nov 2018 02:10:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 47AB5181B9E1; Wed, 21 Nov 2018 02:10:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAL29xli006131 for ; Tue, 20 Nov 2018 21:09:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id C1B2C608C4; Wed, 21 Nov 2018 02:09:59 +0000 (UTC) Received: from magic.redhat.com (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C8A06607B; Wed, 21 Nov 2018 02:09:54 +0000 (UTC) From: Fam Zheng To: patchew-devel@redhat.com Date: Wed, 21 Nov 2018 10:08:40 +0800 Message-Id: <20181121020846.7875-11-famz@redhat.com> In-Reply-To: <20181121020846.7875-1-famz@redhat.com> References: <20181121020846.7875-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: patchew-devel@redhat.com Cc: ymankad@redhat.com, armbru@redhat.com Subject: [Patchew-devel] [PATCH 10/16] maintainer: Update watched queue when getting new message X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 21 Nov 2018 02:10:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Git ResultUpdate is a good point to run the watched queries, because maintainers fiels is populated here. Signed-off-by: Fam Zheng --- 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 =20 class MaintainerModule(PatchewModule): """ Project maintainer related tasks """ =20 name =3D "maintainer" =20 + 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 =3D Queue.objects.get_or_create(user=3Duser, messag= e=3Dx, name=3Dqueue) @@ -33,6 +38,20 @@ class MaintainerModule(PatchewModule): emit_event("MessageDropping", message=3Dq.message, queue=3Dq) q.delete() =20 + def _update_watch_queue(self, series): + se =3D 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 =3D=3D obj.git_result and result.status !=3D result.PEND= ING: + # 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() --=20 2.17.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel