From nobody Mon Sep 16 19:25:20 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; dkim=fail header.i=fam@euphon.net; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543415768594867.2341127274043; Wed, 28 Nov 2018 06:36:08 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D4BD30BC103; Wed, 28 Nov 2018 14:36:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DE65601A8; Wed, 28 Nov 2018 14:36:07 +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 F0CD94A460; Wed, 28 Nov 2018 14:36:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wASEa56u031783 for ; Wed, 28 Nov 2018 09:36:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3500519493; Wed, 28 Nov 2018 14:36:05 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24ABB1948E; Wed, 28 Nov 2018 14:36:05 +0000 (UTC) Received: from sender1.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) by mx1.redhat.com (Postfix) with ESMTP id DEA8C307DAA3; Wed, 28 Nov 2018 14:36:00 +0000 (UTC) Received: from localhost.localdomain (123.112.65.99 [123.112.65.99]) by mx.zoho.com.cn with SMTPS id 1543415756236333.225547987465; Wed, 28 Nov 2018 22:35:56 +0800 (CST) ARC-Seal: i=1; a=rsa-sha256; t=1543415759; cv=none; d=zoho.com.cn; s=zohoarc; b=Vh1/1nkl6E1yp3CaAr0JsRkslFGk73jJIE8bBmKvSVRa77EYKSNED2OyKFtKt00ST/maI0sTJn6Sj/WfeKdXnDXOb79XjsbUPE+K192Y0CoSFelwpLoAHXoWPNOrOhmqCq2DzxPlzNj4OlFXtEx4IPQrT55gCMlZwYxINXA5EM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1543415759; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=E/ZDCY63RQ1cpm8ntxAX/z/rIpbRZFC1wFn4TEG6NIM=; b=IkNisTli5HsfO2ueIeswmknB4bME14+Iz8aFGAmL6uswR/5po+o0CgdO6ChMxZYsQffl8MclJTAUQngmrFIO/G8/ayn3r1+JNd9ZOgE5u68c7gQcX+Y1rgPpWzyc1a/NzNfdz4vkoSV0MIE1mK88FEAWVSNd69nG9HeblID16qI= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=euphon.net; spf=pass smtp.mailfrom=fam@euphon.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1543415759; s=zoho; d=euphon.net; i=fam@euphon.net; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=2317; bh=E/ZDCY63RQ1cpm8ntxAX/z/rIpbRZFC1wFn4TEG6NIM=; b=dDLJpcjXDmIrexAiRREBZIgfZrXUFCZSflVjY9ZFrXJtY1KvopJkaAjCcEsuLbvV 0mMBxFs+3RRJ/DT5iT/AR7ZCYHa3k3n5gNYqLKvAoTRi4vq0wBPi2Z4MRXtVr2cNhog 3oYENec0EmawDZsl++yj7ncfsLlf4T68h43sX65I= From: Fam Zheng To: patchew-devel@redhat.com Date: Wed, 28 Nov 2018 22:35:00 +0800 Message-Id: <20181128143505.27730-8-fam@euphon.net> In-Reply-To: <20181128143505.27730-1-fam@euphon.net> References: <20181128143505.27730-1-fam@euphon.net> X-ZohoCNMailClient: External X-Greylist: Sender passed SPF test, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 28 Nov 2018 14:36:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 28 Nov 2018 14:36:04 +0000 (UTC) for IP:'163.53.93.243' DOMAIN:'sender2-op-o12.zoho.com.cn' HELO:'sender1.zoho.com.cn' FROM:'fam@euphon.net' RCPT:'' X-RedHat-Spam-Score: -0.101 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_PASS) 163.53.93.243 sender2-op-o12.zoho.com.cn 163.53.93.243 sender2-op-o12.zoho.com.cn X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: patchew-devel@redhat.com Cc: Fam Zheng Subject: [Patchew-devel] [PATCH v2 07/12] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 28 Nov 2018 14:36:07 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Fam Zheng Git ResultUpdate is a good point to run the watched queries, because maintainers fiels is populated here. Signed-off-by: Fam Zheng --- api/search.py | 6 ++++++ mods/maintainer.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/api/search.py b/api/search.py index 3067235..a15d238 100644 --- a/api/search.py +++ b/api/search.py @@ -369,3 +369,9 @@ Search text keyword in the email message. Example: self._last_keywords, q) =20 return queryset.filter(q) + + def query_test_message(self, query, message): + queryset =3D Message.objects.filter(id=3Dmessage.id) + terms =3D [x.strip() for x in query.split() if x.strip()] + return self.search_series(*terms, queryset=3Dqueryset).first() + diff --git a/mods/maintainer.py b/mods/maintainer.py index 54738ec..60ed4c4 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()): Queue.objects.get_or_create(user=3Duser, message=3Dx, name=3Dq= ueue) @@ -29,6 +34,20 @@ class MaintainerModule(PatchewModule): name=3Dqueue) 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