From nobody Thu Mar 28 23:22:02 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; 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 1538145950971643.8993471133178; Fri, 28 Sep 2018 07:45:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9ADEBCA39D; Fri, 28 Sep 2018 14:45:49 +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 68466261AA; Fri, 28 Sep 2018 14:45:49 +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 73BE44BB74; Fri, 28 Sep 2018 14:45:48 +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 w8SEjliq024555 for ; Fri, 28 Sep 2018 10:45:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D7212619E; Fri, 28 Sep 2018 14:45:47 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2379C2619C for ; Fri, 28 Sep 2018 14:45:44 +0000 (UTC) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3507C88309 for ; Fri, 28 Sep 2018 14:45:43 +0000 (UTC) Received: by mail-wm1-f51.google.com with SMTP id 189-v6so2186470wmw.2 for ; Fri, 28 Sep 2018 07:45:43 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=fN3GmylKJ4AyxZEhj+K/Ecfn3DN4dTRbpMRAtbRnrFg=; b=bffW6klHifWVXBFP9StKslm+U1GCf/k+/NxErxDneRYmuv2KFaoAhB1TFBN7zW6gj9 cGkGeAHbYe/yQhyP/xbOrSz7Lj4WQTf+kbGtCFlYI/R+mc4M5i1sGFe9GesXvC+u1fM3 PdjPOcql+RDDv7GUgh3Ko1SHhcZ6Jl6Qxw/4gimvzHSmy6HZtw3Q5qmoLj0DV/jkonnl Y15/CV+tCKsWdEkhbACCvCmX2g1WQwgboVdSkY3diE0rY25PfrhI6o1jKBMRyE5oqrlB OWSzYk2NCMnFY/wwL0nZMDzbVmpmmOAD7sQQoq0O1lQ9E0yJzAlhzhggNLIH9wTItjkB g6sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=fN3GmylKJ4AyxZEhj+K/Ecfn3DN4dTRbpMRAtbRnrFg=; b=VeTjnL/Nb/2FRT4OuZRF8/jWJ8K7zyM8wcvrWWCJk7MEj2DPzxvAvUws07yG/nGUrV O6KGieZ4fig3mH3FtZ5s5W+szna0PI4dL731ZRSyu+aTH8oPvF/NeneM/GzeEKwAbNKr n8Pne+IZSX1AUL+7H1+GIqop6FpQakdtpZdGfCjNl+iDtPgcy0jkL4udnwspx72r+gUB 2l/8Jhkps56zElr0fu1nzcmzLjdFkJPh9fEuc4WxUgmDErDR5Lq9KeNpR4l3ONFMcfwp Qyys8YtT+j4oH/UeW09s/Xgwjw+nj9vgfFOvndoLUPjgl3GFINgq6ciYSWvibJQHQZDV eCRA== X-Gm-Message-State: ABuFfohWKWTXaaulcEVmCb1OjlGApDEBwQ9x5X3gRJW5X77IuEgtGn4g Zmfwd92otTHhS/7J2sA4vv32aR9UAjs= X-Google-Smtp-Source: ACcGV61BYfBB6wHK4eW7zMFFbRCP0dWcbOt/tkk3zLAHwvNS3ByvWAbm7IoIKaQeakYhKVSJlo6NUA== X-Received: by 2002:a1c:7711:: with SMTP id t17-v6mr2033468wmi.35.1538145941458; Fri, 28 Sep 2018 07:45:41 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:28 +0200 Message-Id: <20180928144537.5051-2-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 28 Sep 2018 14:45:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 28 Sep 2018 14:45:43 +0000 (UTC) for IP:'209.85.128.51' DOMAIN:'mail-wm1-f51.google.com' HELO:'mail-wm1-f51.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.51 mail-wm1-f51.google.com 209.85.128.51 mail-wm1-f51.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 01/10] search: fix "is:applied" 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 28 Sep 2018 14:45:49 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Convert from message properties to results. Signed-off-by: Paolo Bonzini --- api/search.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/api/search.py b/api/search.py index 63ccfaa..e330ae8 100644 --- a/api/search.py +++ b/api/search.py @@ -8,7 +8,7 @@ # This work is licensed under the MIT License. Please see the LICENSE fil= e or # http://opensource.org/licenses/MIT. =20 -from .models import Message +from .models import Message, Result from django.db.models import Q =20 class InvalidSearchTerm(Exception): @@ -70,6 +70,7 @@ Syntax: - is:complete - the series has all the patches it contains - is:merged - the series is included in the project's git tree - is:pull - the series is a pull request + - is:applied - a git tree is available for the series - has:replies - the series received a reply (apart from patches sent by t= he submitter) =20 Example: @@ -170,10 +171,8 @@ Search text keyword in the email message. Example: ~Q(properties__name=3D"obsoleted-by", properties__value__iexact=3D'') elif cond =3D=3D "applied": - q =3D Q(properties__name=3D"git.tag", - properties__value__isnull=3DFalse) & \ - ~Q(properties__name=3D"git.tag", - properties__value__iexact=3D'') + q =3D Q(results__name=3D"git", + results__status=3DResult.SUCCESS) elif cond =3D=3D "tested": q =3D Q(properties__name=3D"testing.done", properties__value=3D"true") --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 1538145950907524.9289458786051; Fri, 28 Sep 2018 07:45:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A070B80E7B; Fri, 28 Sep 2018 14:45:49 +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 913755E53C; Fri, 28 Sep 2018 14:45:49 +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 67BCE181A12F; Fri, 28 Sep 2018 14:45:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjlCa024560 for ; Fri, 28 Sep 2018 10:45:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id BE7185E1C8; Fri, 28 Sep 2018 14:45:47 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B520217272 for ; Fri, 28 Sep 2018 14:45:45 +0000 (UTC) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 806B830832CD for ; Fri, 28 Sep 2018 14:45:44 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id u12-v6so6681572wrr.4 for ; Fri, 28 Sep 2018 07:45:44 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=kpwvRaa+stoRmXCP6xtA97kkIhmMMkMv4F0ZvvvIIeY=; b=Q28I/WAs5r8hOMKXwWR4Vl/o2bQm8xfTbGBo3/d0kRG4nZXC7rkCOMwehE7D+yz6Iy mnVM5XcQbI52JOpSSnyGIjRPGtyNgSOT2hE5RHEhCGZH2EDIc6n/4O6qAB/0fmnU2zaI Hypv6i4Zg4pJY8K6IEGOK6EHD1xSCPhkdnMfvMRdMV0JorNF2C1m20s+5ZbTPthAldhI n6iMSfINHi2gn5GPzY3YdNCFzR2uDUsqL96VjinjNe+TYtm74eWOgMqSA8Bnwva79GdM ++WSn+0esnMIIAgKgs6/Si3PYb8HGafaq/cooCDj5petVLIsVFM8nxBHTGxifzkZhb83 JN/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=kpwvRaa+stoRmXCP6xtA97kkIhmMMkMv4F0ZvvvIIeY=; b=F6zuAOLugSoiZrdJzZAL+ByAsEhZEI4JS6IUxVFOS6P6wWGufL4ldnvqlpF1scMnt5 Rd/Km8a7CVdFThtFxwHipuQa7nj5sskWVYqAM3Mjq56sHbTtIOB0dmHJ2Qa+LBhA+HWB sPvI7cV7Ba5/SoXgKRX458z5OhCE39ALj8dqyYAJfX3OneB9LEDvp2k+Ezh/UKYOV4bg 4/twntrZA3SnaF9sHVam3L5ZQxuNx1fSYUJTXbxOCd56wm4OZtpUpft0NQunVIhkpYO0 VlxPiNrdQNgbr2C1CfWnN/ulMd5w4ev8knOHl13l3pWj8kfbTBeiv6Rv8NzyO3tk3gMJ CtVw== X-Gm-Message-State: ABuFfoif12+8vUFBJsdWSl+ZLEKzU4VXqa2T3g7jAFclhXZyyvrB7K/6 s2O+VG4HFXbKOPpcnT8gsl2VaK8zTFI= X-Google-Smtp-Source: ACcGV62zg0yke8eFSojMCvUjlQdvY1w+F1LP64Yji01w+a8IB9DwXicbT4dheK+g5suf2eDNPPrhRA== X-Received: by 2002:adf:f991:: with SMTP id f17-v6mr12818171wrr.105.1538145942666; Fri, 28 Sep 2018 07:45:42 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:29 +0200 Message-Id: <20180928144537.5051-3-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 28 Sep 2018 14:45:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 28 Sep 2018 14:45:44 +0000 (UTC) for IP:'209.85.221.47' DOMAIN:'mail-wr1-f47.google.com' HELO:'mail-wr1-f47.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.221.47 mail-wr1-f47.google.com 209.85.221.47 mail-wr1-f47.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 02/10] search: fix matches on property value 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.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 28 Sep 2018 14:45:49 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we have changed the fields to JSONField, we do not need to pass the values as strings. Signed-off-by: Paolo Bonzini --- api/search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/search.py b/api/search.py index e330ae8..17424c3 100644 --- a/api/search.py +++ b/api/search.py @@ -164,7 +164,7 @@ Search text keyword in the email message. Example: q =3D Q(subject__contains=3D'[PULL') | Q(subject__contains= =3D'[GIT PULL') elif cond =3D=3D "reviewed": q =3D Q(properties__name=3D"reviewed", - properties__value=3D"true") + properties__value=3DTrue) elif cond in ("obsoleted", "old"): q =3D Q(properties__name=3D"obsoleted-by", properties__value__isnull=3DFalse) & \ @@ -175,7 +175,7 @@ Search text keyword in the email message. Example: results__status=3DResult.SUCCESS) elif cond =3D=3D "tested": q =3D Q(properties__name=3D"testing.done", - properties__value=3D"true") + properties__value=3DTrue) elif cond =3D=3D "merged": q =3D Q(is_merged=3DTrue) else: --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 1538145951538355.7243006940927; Fri, 28 Sep 2018 07:45:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E39E43A35; Fri, 28 Sep 2018 14:45:50 +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 4DA2C5D73F; Fri, 28 Sep 2018 14:45:50 +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 3D2AD18005CD; Fri, 28 Sep 2018 14:45:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjn6O024575 for ; Fri, 28 Sep 2018 10:45:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8471A2A342; Fri, 28 Sep 2018 14:45:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B8DD5DD87 for ; Fri, 28 Sep 2018 14:45:47 +0000 (UTC) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB2F730821F4 for ; Fri, 28 Sep 2018 14:45:45 +0000 (UTC) Received: by mail-wm1-f52.google.com with SMTP id s12-v6so2512570wmc.0 for ; Fri, 28 Sep 2018 07:45:45 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=Zs3sHFzMyG7kPNixg4dIVXRRNOSg9uOYr5O8JNOH4/s=; b=oRjhJvdBCUWClHhyLXGhQqH+din2QK/vuWuWX3l0gpZN1LtVDnJ6wt69pxRXLGk0YE 2mI9hs2GYtG+csOI5TUDjS/3zhj2aKlZHqg1u/u3WDPMXI49sYKJc22mj3lxaH+5th37 Qjz3b+9xMjYNK+nYzg/7TFYYemIe+xHKhxfgGxAwggo0zvwRpaPFbY5CtrQsyvYVeq7g CHhYXinUsX9AphFlOFdVInCkuQPOwZZ7wW8KgSPFomQeicYy+8fllmlavg0ZybHVHrvA ZohdF3GpiN9P0bVVHNw/jnU+PRA4l1Sx4CwbQvcRp7U4FcpZBT+CtgqNN4YAUxlXpJvQ zYJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=Zs3sHFzMyG7kPNixg4dIVXRRNOSg9uOYr5O8JNOH4/s=; b=sTO2/vYIBGkzEHIxZGPPOgkAUroRfndtYSyk54agbDW3z4pbMW6QFFl98dIpINbXRx uajUq94NVGeLXwcjuhzZVyRrgHlC8gaF/jwPly9jUuOfnUQwzPfMeJ5DubmSveDG/PiS Tqvdt5KATg75k1YtsSFc7sHbkz52LSZJNXdBy5CptJ/DIe7hKOhfT1jPeVufPMmurdeX fQL5CssGqgYaVeeaglBPiT4OsVsurq9mWE59tLSjKROjbaJMtOryxcTCqjlMi66PPu5r Ub6NmlQQmvBwAc9AO+ga3mnH6ekGgAFj0oaan/oCuWsxVcI3Tm8DExWX3Ttb/oaVJ8Vw q51g== X-Gm-Message-State: ABuFfogIlui5qAmfoaxW79qJcP5uj+JAWbc/W4rfmTTKhyX/ne0Zd9QJ 7DNpH8OE9CXaIYD+n7pWCAN1GJPS28A= X-Google-Smtp-Source: ACcGV60VSH3PFw/W2K+EQyxhbUuK6G6NrHPqOzal64H7ChbnTw2iOjcG5K+kaIQJvwXg4i1kt+WRdw== X-Received: by 2002:a1c:ac82:: with SMTP id v124-v6mr2078916wme.10.1538145944225; Fri, 28 Sep 2018 07:45:44 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:30 +0200 Message-Id: <20180928144537.5051-4-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 28 Sep 2018 14:45:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 28 Sep 2018 14:45:46 +0000 (UTC) for IP:'209.85.128.52' DOMAIN:'mail-wm1-f52.google.com' HELO:'mail-wm1-f52.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.52 mail-wm1-f52.google.com 209.85.128.52 mail-wm1-f52.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 03/10] search: introduce _make_filter_subquery 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 28 Sep 2018 14:45:50 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Django is pretty inefficient when related fields are introduced, and sometimes incorrect results are produced (for example "success:testing -failure:testing" does not work if Results are queried through result__* fields). A more efficient (and working) way to achieve the same is to use "IN" with subqueries. Convert is:applied, is:tested and is:obsoleted/is:old to use subqueries. Signed-off-by: Paolo Bonzini --- api/search.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/api/search.py b/api/search.py index 17424c3..b33aa1b 100644 --- a/api/search.py +++ b/api/search.py @@ -8,7 +8,7 @@ # This work is licensed under the MIT License. Please see the LICENSE fil= e or # http://opensource.org/licenses/MIT. =20 -from .models import Message, Result +from .models import Message, MessageProperty, Result from django.db.models import Q =20 class InvalidSearchTerm(Exception): @@ -124,6 +124,10 @@ Search text keyword in the email message. Example: regression =20 """ + def _make_filter_subquery(self, model, q): + message_ids =3D model.objects.filter(q).values('message_id') + return Q(id__in=3Dmessage_ids) + def _process_term(self, query, term, neg=3DFalse): """ Return a Q object that will be applied to the query """ def as_keywords(t): @@ -163,19 +167,15 @@ Search text keyword in the email message. Example: elif cond =3D=3D "pull": q =3D Q(subject__contains=3D'[PULL') | Q(subject__contains= =3D'[GIT PULL') elif cond =3D=3D "reviewed": - q =3D Q(properties__name=3D"reviewed", - properties__value=3DTrue) + q =3D self._make_filter_subquery(MessageProperty, Q(name= =3D"reviewed", value=3DTrue)) elif cond in ("obsoleted", "old"): - q =3D Q(properties__name=3D"obsoleted-by", - properties__value__isnull=3DFalse) & \ - ~Q(properties__name=3D"obsoleted-by", - properties__value__iexact=3D'') + q =3D self._make_filter_subquery(MessageProperty, + Q(name=3D"obsoleted-by", va= lue__isnull=3DFalse) & + ~Q(name=3D"obsoleted-by", v= alue__iexact=3D'')) elif cond =3D=3D "applied": - q =3D Q(results__name=3D"git", - results__status=3DResult.SUCCESS) + q =3D self._make_filter_subquery(MessageResult, Q(name=3D"= git", status=3DResult.SUCCESS)) elif cond =3D=3D "tested": - q =3D Q(properties__name=3D"testing.done", - properties__value=3DTrue) + q =3D self._make_filter_subquery(MessageProperty, Q(name= =3D"testing.done", value=3DTrue)) elif cond =3D=3D "merged": q =3D Q(is_merged=3DTrue) else: --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 1538145955265947.3651983434002; Fri, 28 Sep 2018 07:45:55 -0700 (PDT) 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 19F123097075; Fri, 28 Sep 2018 14:45:54 +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 07B50600C7; Fri, 28 Sep 2018 14:45:54 +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 ECE554BB74; Fri, 28 Sep 2018 14:45:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjqxj024597 for ; Fri, 28 Sep 2018 10:45:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8F85E3066752; Fri, 28 Sep 2018 14:45:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84B083001A47 for ; Fri, 28 Sep 2018 14:45:48 +0000 (UTC) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 018E930820C1 for ; Fri, 28 Sep 2018 14:45:47 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id j15-v6so6670537wrt.8 for ; Fri, 28 Sep 2018 07:45:46 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=CKzC8ZPye34WAD5FBL6biQTO3SLSJehHdIoN8PgT2GM=; b=sSrOXGcamgfjNK08x6sdaK5KSdsrJSe/dhARAaY7uRcNPFlRr4UN64H2JpnknJVElR Ei1ESsSA+9DeD0+JZlf0W8JaEWXT2EL7JE3u3Xg0S5CCsSqG7c3QhLypcuE/w+bPayMj vQhvA0N5MnR1+4CnqmdQr0pfEhZp+5XJ9SOEBvnZpj9utzkWzc4Omo4TPyyC+FtmvACf VuroNx5pTDORFSFATrLD/OK670MOog2Jye6dMlKQGX0BsEoRz8wLiUVKNSH7K1846lr6 VKM/yR098ma4B32O/OGjK1rdUzqvGtd+CzQ9f1XeSbi2+S5D5K3W6PHGF7khxquYMPoa qEkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=CKzC8ZPye34WAD5FBL6biQTO3SLSJehHdIoN8PgT2GM=; b=GVxZg/rpbX4neTtqtbHf3fT9b/2p9o24zYzQ8PUK3lrxQpziQCRJZAm8TeVRYF7mHO QjsHO+JMwttS7cj05Dfsy8Z4nRp2A6PopGl9GXpqtM9xOdOu4jNxhkEBQK+AqEfrLSvH xZNdkZfq81HYTwcrLuqJjB/NenF09SEcg48hxng1e8PGe5dB68N17rKfiKtU8wb4KvkK mCDfGCFqZ7K9c5ftp7dsjbWboAWBbnr+cb8btRBY8EAe1SaIK48TN16SBHiSbAAon+4v z2iXVQ1MZG6jU3VjanSZyX2R65NkLhMTRzMM9SRWNTMVqLAoHFs0Ll/KsnR5kCokmni7 w2tw== X-Gm-Message-State: ABuFfogGZLG2ye8j+iYvXCz7jmUwoVRjuVKRzgYiT+GJtumk8yJ9CDwd Y+C66Lz+NXkpw2EqztPvQlZDP+oyHAk= X-Google-Smtp-Source: ACcGV62+pfVX/RPB0jhD58Bey1obdx0+GPPue9NfCEf1VdCR6CNU6llCz5wzlA234Ba6xBeHovERQA== X-Received: by 2002:adf:f5c6:: with SMTP id k6-v6mr2441940wrp.59.1538145945278; Fri, 28 Sep 2018 07:45:45 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:31 +0200 Message-Id: <20180928144537.5051-5-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 28 Sep 2018 14:45:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 28 Sep 2018 14:45:47 +0000 (UTC) for IP:'209.85.221.52' DOMAIN:'mail-wr1-f52.google.com' HELO:'mail-wr1-f52.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.489 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.221.52 mail-wr1-f52.google.com 209.85.221.52 mail-wr1-f52.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 04/10] search: move queryset out of _process_term 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.43]); Fri, 28 Sep 2018 14:45:54 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make _process_term return a Q object as mentioned in the doc comment, rather than a QuerySet. Signed-off-by: Paolo Bonzini --- api/search.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/api/search.py b/api/search.py index b33aa1b..b1d20ec 100644 --- a/api/search.py +++ b/api/search.py @@ -9,6 +9,7 @@ # http://opensource.org/licenses/MIT. =20 from .models import Message, MessageProperty, Result +from functools import reduce from django.db.models import Q =20 class InvalidSearchTerm(Exception): @@ -128,19 +129,19 @@ Search text keyword in the email message. Example: message_ids =3D model.objects.filter(q).values('message_id') return Q(id__in=3Dmessage_ids) =20 - def _process_term(self, query, term, neg=3DFalse): + def _process_term(self, term, neg=3DFalse): """ Return a Q object that will be applied to the query """ def as_keywords(t): self._last_keywords.append(t) return Q(subject__icontains=3Dt) =20 if term.startswith("!"): - return self._process_term(query, term[1:], not neg) + return self._process_term(term[1:], not neg) if term.startswith("age:"): cond =3D term[term.find(":") + 1:] - q =3D self._process_age_term(query, cond) + q =3D self._process_age_term(cond) elif term[0] in "<>" and len(term) > 1: - q =3D self._process_age_term(query, term) + q =3D self._process_age_term(term) elif term.startswith("from:"): cond =3D term[term.find(":") + 1:] q =3D Q(sender__icontains=3Dcond) @@ -196,9 +197,9 @@ Search text keyword in the email message. Example: # Keyword in subject is the default q =3D as_keywords(term) if neg: - return query.exclude(pk__in=3Dquery.filter(q)) + return ~q else: - return query.filter(q) + return q =20 def last_keywords(self): return getattr(self, "_last_keywords", []) @@ -209,13 +210,13 @@ Search text keyword in the email message. Example: def search_series(self, *terms, queryset=3DNone): self._last_keywords =3D [] self._projects =3D set() + q =3D reduce(lambda x, y: x & y, + map(lambda t: self._process_term(t), terms), Q()) if queryset is None: queryset =3D Message.objects.series_heads() - for t in terms: - queryset =3D self._process_term(queryset, t) - return queryset + return queryset.filter(q) =20 - def _process_age_term(self, query, cond): + def _process_age_term(self, cond): import datetime def human_to_seconds(n, unit): if unit =3D=3D "d": --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 1538145953140882.6281767469725; Fri, 28 Sep 2018 07:45:53 -0700 (PDT) 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 C2EB33097031; Fri, 28 Sep 2018 14:45:51 +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 AFABF5DD87; Fri, 28 Sep 2018 14:45:51 +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 A050318005CD; Fri, 28 Sep 2018 14:45:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjoUH024580 for ; Fri, 28 Sep 2018 10:45:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C67A2010DA4; Fri, 28 Sep 2018 14:45:50 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F39BD2010DA2 for ; Fri, 28 Sep 2018 14:45:49 +0000 (UTC) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 28069C05D3E5 for ; Fri, 28 Sep 2018 14:45:48 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id y26-v6so2501924wma.2 for ; Fri, 28 Sep 2018 07:45:48 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=rKhum7HJHP/40cTnurEVrgB753X78tREV3nRqNpZK+M=; b=R3VX8jLqoFuu/jW/cjIDOrYGSCLmdgDnLWQKDxT4rT/fzaKO6jXPgDQWA7J/C0/gKe nPUA0/jEU9zMn3N7syKd5/kmbdSE+FEg5uvdLz3kBVrLq6Q1iXNvb40bPOchJKeu62S3 i/MWigdSOaQAPoL2FvpZvIl+NKJhrhpkrP/VA2l7HVOfYSjyqyjFqBK6h/fkyMnilQn1 1CPmen1ULLmse+0ckgOojb/Z/6QVuHkQ6gM0T/0RLVqeGPT2T+aWj+bB04WibnNiaU/p HVGpTctApY4lvgzhbt1dXR2CXc5vxGxoF3cSrbW0sFMEeiNGZCU6Pwkh7+O8Mdj/TjW3 Eg/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=rKhum7HJHP/40cTnurEVrgB753X78tREV3nRqNpZK+M=; b=MiY1YtXoNHXqvvoHHhz9D+FeYmySiwghdftRS79toYz3/XyfayfoWT1nExWIhntrX6 BkFdC1xnveTjBw6PX1KLZs+S1366ciC4gEfMnx1l8WNWSbZMmkuHhU9oOtdQiAkKKTsi WrhyKZoJL14UtEntZDycTnWOubrR3aHqJUXR9ehSk2hUxrtU9LxfHrR0PkbBXxQdF3Gi 7mo/BFwAPA6VxpWPUrW2SjVv+c45En+gHDkC6WppXYNb4wuUu3Na/87a7u7T0wj2p7mh A7H8DVB6STjyd3G8HaMpDYgX36igGm4eoIQa5neCuQ4qXD1MLFM6sRTUD/hvfvSVxcWv ayqQ== X-Gm-Message-State: ABuFfojGVVVn2joMqsGL3jYxWKekdLG8qBa6+C22w2qTd5AHYxyxORz+ I2biFHjlbKhX23QpLi5PjiA+JoL8hR8= X-Google-Smtp-Source: ACcGV61VMk2gWRXNX8xtGLTMeXBp5JMCL8/xC0xAHQgno4kFb75Ig2E2th0BVoV4rwftoJnbu9pqnw== X-Received: by 2002:a1c:4a:: with SMTP id 71-v6mr1942072wma.96.1538145946346; Fri, 28 Sep 2018 07:45:46 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:32 +0200 Message-Id: <20180928144537.5051-6-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 28 Sep 2018 14:45:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 28 Sep 2018 14:45:48 +0000 (UTC) for IP:'209.85.128.45' DOMAIN:'mail-wm1-f45.google.com' HELO:'mail-wm1-f45.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.45 mail-wm1-f45.google.com 209.85.128.45 mail-wm1-f45.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 05/10] search: split _process_term into separate functions 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.43]); Fri, 28 Sep 2018 14:45:51 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is a first step towards turning it into something like a recursive descent parser. --- api/search.py | 116 +++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/api/search.py b/api/search.py index b1d20ec..355de0e 100644 --- a/api/search.py +++ b/api/search.py @@ -129,19 +129,70 @@ Search text keyword in the email message. Example: message_ids =3D model.objects.filter(q).values('message_id') return Q(id__in=3Dmessage_ids) =20 + def _make_filter_age(self, cond): + import datetime + def human_to_seconds(n, unit): + if unit =3D=3D "d": + return n * 86400 + elif unit =3D=3D "w": + return n * 86400 * 7 + elif unit =3D=3D "m": + return n * 86400 * 30 + elif unit =3D=3D "y": + return n * 86400 * 365 + raise Exception("No unit specified") + + if cond.startswith("<"): + less =3D True + cond =3D cond[1:] + elif cond.startswith(">"): + less =3D False + cond =3D cond[1:] + else: + less =3D False + num, unit =3D cond[:-1], cond[-1].lower() + if not num.isdigit() or not unit in "dwmy": + raise InvalidSearchTerm("Invalid age string: %s" % cond) + sec =3D human_to_seconds(int(num), unit) + p =3D datetime.datetime.now() - datetime.timedelta(0, sec) + if less: + q =3D Q(date__gte=3Dp) + else: + q =3D Q(date__lte=3Dp) + return q + + def _make_filter_keywords(self, t): + self._last_keywords.append(t) + return Q(subject__icontains=3Dt) + + def _make_filter_is(self, cond): + if cond =3D=3D "complete": + return Q(is_complete=3DTrue) + elif cond =3D=3D "pull": + return Q(subject__contains=3D'[PULL') | Q(subject__contains=3D= '[GIT PULL') + elif cond =3D=3D "reviewed": + return self._make_filter_subquery(MessageProperty, Q(name=3D"r= eviewed", value=3DTrue)) + elif cond in ("obsoleted", "old"): + return self._make_filter_subquery(MessageProperty, + Q(name=3D"obsoleted-by", val= ue__isnull=3DFalse) & + ~Q(name=3D"obsoleted-by", va= lue__iexact=3D'')) + elif cond =3D=3D "applied": + return self._make_filter_subquery(MessageResult, Q(name=3D"git= ", status=3DResult.SUCCESS)) + elif cond =3D=3D "tested": + return self._make_filter_subquery(MessageProperty, Q(name=3D"t= esting.done", value=3DTrue)) + elif cond =3D=3D "merged": + return Q(is_merged=3DTrue) + return self._make_filter_keywords(cond) + def _process_term(self, term, neg=3DFalse): """ Return a Q object that will be applied to the query """ - def as_keywords(t): - self._last_keywords.append(t) - return Q(subject__icontains=3Dt) - if term.startswith("!"): return self._process_term(term[1:], not neg) if term.startswith("age:"): cond =3D term[term.find(":") + 1:] - q =3D self._process_age_term(cond) + q =3D self._make_filter_age(cond) elif term[0] in "<>" and len(term) > 1: - q =3D self._process_age_term(term) + q =3D self._make_filter_age(term) elif term.startswith("from:"): cond =3D term[term.find(":") + 1:] q =3D Q(sender__icontains=3Dcond) @@ -163,26 +214,9 @@ Search text keyword in the email message. Example: else: cond =3D term[term.find(":") + 1:] lneg =3D term.startswith("not:") - if cond =3D=3D "complete": - q =3D Q(is_complete=3DTrue) - elif cond =3D=3D "pull": - q =3D Q(subject__contains=3D'[PULL') | Q(subject__contains= =3D'[GIT PULL') - elif cond =3D=3D "reviewed": - q =3D self._make_filter_subquery(MessageProperty, Q(name= =3D"reviewed", value=3DTrue)) - elif cond in ("obsoleted", "old"): - q =3D self._make_filter_subquery(MessageProperty, - Q(name=3D"obsoleted-by", va= lue__isnull=3DFalse) & - ~Q(name=3D"obsoleted-by", v= alue__iexact=3D'')) - elif cond =3D=3D "applied": - q =3D self._make_filter_subquery(MessageResult, Q(name=3D"= git", status=3DResult.SUCCESS)) - elif cond =3D=3D "tested": - q =3D self._make_filter_subquery(MessageProperty, Q(name= =3D"testing.done", value=3DTrue)) - elif cond =3D=3D "merged": - q =3D Q(is_merged=3DTrue) - else: - q =3D as_keywords(term) if lneg: neg =3D not neg + q =3D self._make_filter_is(cond) elif term.startswith("has:"): cond =3D term[term.find(":") + 1:] if cond =3D=3D "replies": @@ -195,7 +229,7 @@ Search text keyword in the email message. Example: q =3D Q(project__name=3Dcond) | Q(project__parent_project__nam= e=3Dcond) else: # Keyword in subject is the default - q =3D as_keywords(term) + q =3D self._make_filter_keywords(term) if neg: return ~q else: @@ -215,35 +249,3 @@ Search text keyword in the email message. Example: if queryset is None: queryset =3D Message.objects.series_heads() return queryset.filter(q) - - def _process_age_term(self, cond): - import datetime - def human_to_seconds(n, unit): - if unit =3D=3D "d": - return n * 86400 - elif unit =3D=3D "w": - return n * 86400 * 7 - elif unit =3D=3D "m": - return n * 86400 * 30 - elif unit =3D=3D "y": - return n * 86400 * 365 - raise Exception("No unit specified") - - if cond.startswith("<"): - less =3D True - cond =3D cond[1:] - elif cond.startswith(">"): - less =3D False - cond =3D cond[1:] - else: - less =3D False - num, unit =3D cond[:-1], cond[-1].lower() - if not num.isdigit() or not unit in "dwmy": - raise InvalidSearchTerm("Invalid age string: %s" % cond) - sec =3D human_to_seconds(int(num), unit) - p =3D datetime.datetime.now() - datetime.timedelta(0, sec) - if less: - q =3D Q(date__gte=3Dp) - else: - q =3D Q(date__lte=3Dp) - return q --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 1538145958344384.4104076779497; Fri, 28 Sep 2018 07:45:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 325208667B; Fri, 28 Sep 2018 14:45:57 +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 21DB25D778; Fri, 28 Sep 2018 14:45:57 +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 1062C4BB74; Fri, 28 Sep 2018 14:45:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjsd5024622 for ; Fri, 28 Sep 2018 10:45:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id E5BDD5D778; Fri, 28 Sep 2018 14:45:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB42E5D73F for ; Fri, 28 Sep 2018 14:45:50 +0000 (UTC) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BB6C3DD47 for ; Fri, 28 Sep 2018 14:45:49 +0000 (UTC) Received: by mail-wm1-f53.google.com with SMTP id q8-v6so2485822wmq.4 for ; Fri, 28 Sep 2018 07:45:49 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=mhgKOOtuQl7lDe11UQVeTX87EsjUAnNhC2tjRtzn5qM=; b=RnpQAECcSel133lQ2jcNucnZx7dfSOHv9XH8kMHstAyedXYf5co8TBnpprVb0LDG4k 7hKECwsCMUaHm6+Lt0pdgsy8U3KTm7mPwOnaVORpmdv6/4DoIanREQe1MMF6sk/xqWtN mrL0VNH29R3Wun/fzViG5mOQlTCuE+L4bEgrpPazuXY4XodOCMe3lnmO97NDYZmrq4xL UC5fiavHfOGc5g7a5TjBsUX72kg8B7IGvJid4oc0T/4k7+drry5M1bcaYuXlki15W/Nr 4ilWtXXZlk5eFyzAv2meU4Q1C6pt86PJBYKLABKN8LswgwTPwlApVBjgWlkbVRUcFs9U NU3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=mhgKOOtuQl7lDe11UQVeTX87EsjUAnNhC2tjRtzn5qM=; b=TISStCPZTpgoWN8Y4T1/Un9ZMNoqx5OXbM/ZBVu6c433b4ekWIQba8CSgTxqFmYdZP 4kFtuVnSk0wnJ++Lq6OiDjYlHG2oEjMAmypqAvkS4Uq2F3an2xPXkBOYCmp+u9SyZXZk nX6NQRDsa21IWVYy8lsRz5aU91r1eLKUf9loDahe3poOstL0sLiXp0ZxWegMnpQVZF24 +rzVTdpEBZnPKquVRO0a+1am3F+HLFOTDY0gq3j0pMz4Yv7Mnj0enKT4eUQj4ra8VH7h ONlShbu7Achjb2BPTgFS/ImbNQBmCMgBQtzfvza7I9tOblS4e9+zH3fJC4G0sGdUdmbZ eSFA== X-Gm-Message-State: ABuFfogjR3NN1vnyGqRlaJbuARD8dnF/kT6sDny0PkBlGn+/EITqYgS3 VT12c0SNQM7XemM/vSyv470VhCPsTjw= X-Google-Smtp-Source: ACcGV63TlQF6Vxqkb2rrGs6RGt3t32SaXHvOCR8Se5V/TA1pE+WzVGjhwg/h+qTBK3V/HRPEAGwF7Q== X-Received: by 2002:a1c:c145:: with SMTP id r66-v6mr2013958wmf.131.1538145947547; Fri, 28 Sep 2018 07:45:47 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:33 +0200 Message-Id: <20180928144537.5051-7-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 28 Sep 2018 14:45:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 28 Sep 2018 14:45:49 +0000 (UTC) for IP:'209.85.128.53' DOMAIN:'mail-wm1-f53.google.com' HELO:'mail-wm1-f53.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.53 mail-wm1-f53.google.com 209.85.128.53 mail-wm1-f53.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 06/10] search: split handling of anything but +/-/! to a separate function, simplify ! 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Sep 2018 14:45:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Define "+" as "imply an is: if there is no colon" and "-" as "imply a not: if there is no colon". It is possible however to write "-has:replies" for example. For simplicity, only allow one of +/-/!. It is not possible anymore to write "!!x" to mean "x". The advantage is that _make_filter can just return the Q object directly. Signed-off-by: Paolo Bonzini --- api/search.py | 59 ++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/api/search.py b/api/search.py index 355de0e..90e6596 100644 --- a/api/search.py +++ b/api/search.py @@ -78,6 +78,9 @@ Example: =20 is:reviewed =20 +"not:X" is the opposite of "is:X". "+X" and "-X" are shorter synonyms of "= is:X" +and "not:X" respectively. + --- =20 ### Search addresses @@ -182,54 +185,58 @@ Search text keyword in the email message. Example: return self._make_filter_subquery(MessageProperty, Q(name=3D"t= esting.done", value=3DTrue)) elif cond =3D=3D "merged": return Q(is_merged=3DTrue) - return self._make_filter_keywords(cond) + return None =20 - def _process_term(self, term, neg=3DFalse): - """ Return a Q object that will be applied to the query """ - if term.startswith("!"): - return self._process_term(term[1:], not neg) + def _make_filter(self, term): if term.startswith("age:"): cond =3D term[term.find(":") + 1:] - q =3D self._make_filter_age(cond) + return self._make_filter_age(cond) elif term[0] in "<>" and len(term) > 1: - q =3D self._make_filter_age(term) + return self._make_filter_age(term) elif term.startswith("from:"): cond =3D term[term.find(":") + 1:] - q =3D Q(sender__icontains=3Dcond) + return Q(sender__icontains=3Dcond) elif term.startswith("to:"): cond =3D term[term.find(":") + 1:] - q =3D Q(recipients__icontains=3Dcond) + return Q(recipients__icontains=3Dcond) elif term.startswith("subject:"): cond =3D term[term.find(":") + 1:] - q =3D Q(subject__icontains=3Dcond) + return Q(subject__icontains=3Dcond) elif term.startswith("id:"): cond =3D term[term.find(":") + 1:] if cond[0] =3D=3D "<" and cond[-1] =3D=3D ">": cond =3D cond[1:-1] - q =3D Q(message_id=3Dcond) - elif term.startswith("is:") or term.startswith("not:") or term[0] = in "+-": - if term[0] in "+-": - cond =3D term[1:] - lneg =3D term[0] =3D=3D "-" - else: - cond =3D term[term.find(":") + 1:] - lneg =3D term.startswith("not:") - if lneg: - neg =3D not neg - q =3D self._make_filter_is(cond) + return Q(message_id=3Dcond) + elif term.startswith("is:"): + return self._make_filter_is(term[3:]) or self._make_filter_key= words(term) + elif term.startswith("not:"): + return ~self._make_filter_is(term[4:]) or self._make_filter_ke= ywords(term) elif term.startswith("has:"): cond =3D term[term.find(":") + 1:] if cond =3D=3D "replies": - q =3D Q(last_comment_date__isnull=3DFalse) + return Q(last_comment_date__isnull=3DFalse) else: - q =3D Q(properties__name=3Dcond) + return Q(properties__name=3Dcond) elif term.startswith("project:"): cond =3D term[term.find(":") + 1:] self._projects.add(cond) - q =3D Q(project__name=3Dcond) | Q(project__parent_project__nam= e=3Dcond) + return Q(project__name=3Dcond) | Q(project__parent_project__na= me=3Dcond) + + # Keyword in subject is the default + return self._make_filter_keywords(term) + + def _process_term(self, term): + """ Return a Q object that will be applied to the query """ + is_plusminus =3D neg =3D False + if term[0] in "+-!": + neg =3D (term[0] !=3D "+") + is_plusminus =3D (term[0] !=3D "!") + term =3D term[1:] + + if is_plusminus and ":" not in term: + q =3D self._make_filter_is(term) or self._make_filter_keywords= (term) else: - # Keyword in subject is the default - q =3D self._make_filter_keywords(term) + q =3D self._make_filter(term) if neg: return ~q else: --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 1538145958305576.6750711539913; Fri, 28 Sep 2018 07:45:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 044F930001E7; Fri, 28 Sep 2018 14:45:57 +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 E9CEE261AB; Fri, 28 Sep 2018 14:45:56 +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 D84214BB74; Fri, 28 Sep 2018 14:45:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjsWq024613 for ; Fri, 28 Sep 2018 10:45:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79170600CD; Fri, 28 Sep 2018 14:45:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70CC2600C7 for ; Fri, 28 Sep 2018 14:45:51 +0000 (UTC) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4631B86647 for ; Fri, 28 Sep 2018 14:45:50 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id r1-v6so2019951wmh.0 for ; Fri, 28 Sep 2018 07:45:50 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=lJz9Pknhhl5moG+1ybKTzJDQV0njV5vqElewJawA+Kw=; b=TcbSdqsU+EDf/aTUEQjwAWmkjacF4i6MI3yB/jpgIZ3N6/LkpDKZGF6/tcGJ0qqf+t lmYNxdYI3Pju6K2TfD5hIlAyEU+eyeKHZBNNK5owKduHmAr3/CLQavvTNZRUCujm0gsr D70o13NbRG5YK18LoAoEWUSjFlVWUDh7qG9hiw4Y5po80N9/jHEGTadDke4ZFTbAeqpr ONGbP3MrdqyMZkjwbu6NbRO0KqqZEVUfrxsCZn4zvOjF0N6iv5ayilCpr5FKIm6momE5 hMiQY8/FUUdBdi4ZeQsoB+xqZREv98sntpusUR8fWUw+oGyely2obOBr6wXy4nqe204G qJ6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=lJz9Pknhhl5moG+1ybKTzJDQV0njV5vqElewJawA+Kw=; b=o5g8u+G3NRAn7czRyNeLLAApvGDieyqOJAvvpIJJX+5455RiQVeOz1KEVFT1b+Z0D/ GI4lWOz3+RX4V0riwAPhtbGZcyv4yRkdcK7REz51uPMPZUf0aKZRk4+tvMlPlPoiV5Bq 8ORNtf8NzHe4bkSh53PF1Bl0ZyNSXZ0FMTmw5ElYNNGDpQH2gVW1NYzJgRIyzjYm3zzI PZYn+Am7vxvnV07dXc+VaYuaFGwcNnglOJEJ9e7GXFZt/NPJ2o36CH9c7ivOKdUJstLn onx2jAEw3xZZx8ytgtFpBDwFx69F771zbJME18XZy8dyiLBzfJunaNxq+tWu/WwcfEb2 h+cw== X-Gm-Message-State: ABuFfoizp+WUQyK/jAnR7r4jstg/R79EjlRG/wuedkBL4ultmjOnhfXg jWUlVSSy1l4x1mpFE83dF192av92e5Y= X-Google-Smtp-Source: ACcGV62nn9t/qmeP95qOIzvzRHdwSlGA5LNN5yc/w1hZtYpDURugbPJv1Kmmftl+Z99TGZZiqVvezw== X-Received: by 2002:a1c:b20d:: with SMTP id b13-v6mr1974542wmf.141.1538145948555; Fri, 28 Sep 2018 07:45:48 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:34 +0200 Message-Id: <20180928144537.5051-8-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Sep 2018 14:45:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Sep 2018 14:45:50 +0000 (UTC) for IP:'209.85.128.45' DOMAIN:'mail-wm1-f45.google.com' HELO:'mail-wm1-f45.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.45 mail-wm1-f45.google.com 209.85.128.45 mail-wm1-f45.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 07/10] search: add search by result 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 28 Sep 2018 14:45:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- api/search.py | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/api/search.py b/api/search.py index 90e6596..a2644c5 100644 --- a/api/search.py +++ b/api/search.py @@ -8,10 +8,23 @@ # This work is licensed under the MIT License. Please see the LICENSE fil= e or # http://opensource.org/licenses/MIT. =20 -from .models import Message, MessageProperty, Result +from .models import Message, MessageProperty, MessageResult, Result from functools import reduce from django.db.models import Q =20 +from django.db.models import Lookup +from django.db.models.fields import Field + +@Field.register_lookup +class NotEqual(Lookup): + lookup_name =3D 'ne' + + def as_sql(self, compiler, connection): + lhs, lhs_params =3D self.process_lhs(compiler, connection) + rhs, rhs_params =3D self.process_rhs(compiler, connection) + params =3D lhs_params + rhs_params + return '%s <> %s' % (lhs, rhs), params + class InvalidSearchTerm(Exception): pass =20 @@ -94,6 +107,21 @@ Compare the address info of message. Example: =20 --- =20 +### Search by result + +Syntax: + + - pending:NAME, success:NAME, failure:NAME, running:NAME + +where NAME can be e.g. "git", "testing", "testing.TEST-NAME" + +Example: + + success:git + failure:testing.FreeBSD + +--- + ### Reverse condition =20 - Syntax: !TERM @@ -132,6 +160,10 @@ Search text keyword in the email message. Example: message_ids =3D model.objects.filter(q).values('message_id') return Q(id__in=3Dmessage_ids) =20 + def _make_filter_result(self, term, **kwargs): + q =3D Q(name=3Dterm, **kwargs) | Q(name__startswith=3Dterm+'.', **= kwargs) + return self._make_filter_subquery(MessageResult, q) + def _make_filter_age(self, cond): import datetime def human_to_seconds(n, unit): @@ -217,6 +249,17 @@ Search text keyword in the email message. Example: return Q(last_comment_date__isnull=3DFalse) else: return Q(properties__name=3Dcond) + elif term.startswith("failure:"): + return self._make_filter_result(term[8:], status=3DResult.FAIL= URE) + elif term.startswith("success:"): + # What we want is "all results are successes", but the only wa= y to + # express it is "there is a result and not (any result is not = a success)". + return self._make_filter_result(term[8:]) \ + & ~self._make_filter_result(term[8:], status__ne=3DResult.= SUCCESS) + elif term.startswith("pending:"): + return self._make_filter_result(term[8:], status=3DResult.PEND= ING) + elif term.startswith("running:"): + return self._make_filter_result(term[8:], status=3DResult.RUNN= ING) elif term.startswith("project:"): cond =3D term[term.find(":") + 1:] self._projects.add(cond) --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 1538145958789339.6362234698562; Fri, 28 Sep 2018 07:45:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83BB43082A2F; Fri, 28 Sep 2018 14:45:57 +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 6A4E065963; Fri, 28 Sep 2018 14:45:57 +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 5B91D18005CD; Fri, 28 Sep 2018 14:45:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjsYS024612 for ; Fri, 28 Sep 2018 10:45:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7884B600CC; Fri, 28 Sep 2018 14:45:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70BB0600C1 for ; Fri, 28 Sep 2018 14:45:52 +0000 (UTC) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 642C3307D857 for ; Fri, 28 Sep 2018 14:45:51 +0000 (UTC) Received: by mail-wm1-f49.google.com with SMTP id s12-v6so2512958wmc.0 for ; Fri, 28 Sep 2018 07:45:51 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=gKWvn2Vm360TYtdvtBk0tUFdU11CtIZ3g1iMTo0WFfg=; b=S5GmInsN5pO4JbuT7yEu98/Lzeq2/kpSdL+UTv+bPbdIuXay1fNjr+QqwDDA7ypjGk GDPT0QRPN0wkD3gK9A96ytrk2m4EvxTq+BypHy7LpwixiOcEoHYKGx254VHnjPtN/kin UK9asr7heY3eTiVrXppe3Ux3XunoX/mu80AXQrGjyKpc8/CJYc+KdtjP0c+8pkw4yxCS W8hfHlAjz9OR4MH2lJY9VMeIOF5V/M2trGu7bIQh4g6VK8gN4g/znLj2heNWAFr+03Wm PvyXoBc0+BfCgoWnDESQHjRlqPdHcEfisV/rUMyizRSjcFFPzdQHFclI0QcIar0sBsrR xj/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=gKWvn2Vm360TYtdvtBk0tUFdU11CtIZ3g1iMTo0WFfg=; b=fOVRg3Rn4ZX9ju9SGrXXXTjt8+AxlZvUgSYkmFjxgwmpLnxy8sdVImrSpbbQ4j9p7V mtX6kjVwpZnZBU6wExV3b02HDHszWrITviUR/7VPvHYyjSktwr9HMC31bSlz57NIXnrv YsQkfqBT0JAuw8PyRe+5k3LY5H+mjb6Vdso6pxKErc1OWX8mI+jEgWQBb3RgS0iFtsQt oxdhSSwTIcZU+2A3L1lmp1d2ci1Yc+tnBUX24q2tBZx8F3pbAN3nmnGA3tVowkszj/d0 NtBPI8tTElzwKUAyFDGRMQONiguTnkTPQZ6WEjRrXH70mLCMUWOkF8rj1SFf47lk9wPt toYQ== X-Gm-Message-State: ABuFfohOocStc/KMpOQCxx3rKymbkQ0fTV8Rvf+Ly7bjE1rZqlGVeYcV ajB85Nhmo/PSCOJmE0a80GOrCvRSzqQ= X-Google-Smtp-Source: ACcGV62etz5Ny42Y14/FKzbMqrIOkW1pWekfqf9sYCXSu07xVseOvbz/ljWLzhW27X8qNzMCQtjfGw== X-Received: by 2002:a1c:f312:: with SMTP id q18-v6mr1806699wmq.14.1538145949656; Fri, 28 Sep 2018 07:45:49 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:35 +0200 Message-Id: <20180928144537.5051-9-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 28 Sep 2018 14:45:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 28 Sep 2018 14:45:51 +0000 (UTC) for IP:'209.85.128.49' DOMAIN:'mail-wm1-f49.google.com' HELO:'mail-wm1-f49.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.489 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.128.49 mail-wm1-f49.google.com 209.85.128.49 mail-wm1-f49.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 08/10] search: pass user to search 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 28 Sep 2018 14:45:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This will be used to support reviews. Signed-off-by: Paolo Bonzini --- api/rest.py | 2 +- api/search.py | 11 ++++++----- api/views.py | 4 ++-- mods/testing.py | 2 +- www/views.py | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/api/rest.py b/api/rest.py index 9a8ec1e..8789e25 100644 --- a/api/rest.py +++ b/api/rest.py @@ -344,7 +344,7 @@ class PatchewSearchFilter(filters.BaseFilterBackend): search =3D request.query_params.get(self.search_param) or '' terms =3D [x.strip() for x in search.split(" ") if x] se =3D SearchEngine() - query =3D se.search_series(queryset=3Dqueryset, *terms) + query =3D se.search_series(queryset=3Dqueryset, user=3Drequest.use= r, *terms) return query =20 def to_html(self, request, queryset, view): diff --git a/api/search.py b/api/search.py index a2644c5..cf3c145 100644 --- a/api/search.py +++ b/api/search.py @@ -219,7 +219,7 @@ Search text keyword in the email message. Example: return Q(is_merged=3DTrue) return None =20 - def _make_filter(self, term): + def _make_filter(self, term, user): if term.startswith("age:"): cond =3D term[term.find(":") + 1:] return self._make_filter_age(cond) @@ -268,7 +268,7 @@ Search text keyword in the email message. Example: # Keyword in subject is the default return self._make_filter_keywords(term) =20 - def _process_term(self, term): + def _process_term(self, term, user): """ Return a Q object that will be applied to the query """ is_plusminus =3D neg =3D False if term[0] in "+-!": @@ -279,7 +279,7 @@ Search text keyword in the email message. Example: if is_plusminus and ":" not in term: q =3D self._make_filter_is(term) or self._make_filter_keywords= (term) else: - q =3D self._make_filter(term) + q =3D self._make_filter(term, user) if neg: return ~q else: @@ -291,11 +291,12 @@ Search text keyword in the email message. Example: def project(self): return next(iter(self._projects)) if len(self._projects) =3D=3D 1 = else None =20 - def search_series(self, *terms, queryset=3DNone): + def search_series(self, *terms, user=3DNone, queryset=3DNone): self._last_keywords =3D [] self._projects =3D set() q =3D reduce(lambda x, y: x & y, - map(lambda t: self._process_term(t), terms), Q()) + map(lambda t: self._process_term(t, user), terms), + Q()) if queryset is None: queryset =3D Message.objects.series_heads() return queryset.filter(q) diff --git a/api/views.py b/api/views.py index f2262b6..32bceab 100644 --- a/api/views.py +++ b/api/views.py @@ -185,7 +185,7 @@ class SearchView(APIView): =20 def handle(self, request, terms, fields=3DNone): se =3D SearchEngine() - r =3D se.search_series(*terms) + r =3D se.search_series(user=3Drequest.user, *terms) return [prepare_series(request, x, fields) for x in r] =20 class ImportView(APILoginRequiredView): @@ -211,7 +211,7 @@ class DeleteView(APILoginRequiredView): Message.objects.all().delete() else: se =3D SearchEngine() - for r in se.search_series(*terms): + for r in se.search_series(user=3Drequest.user, *terms): Message.objects.delete_subthread(r) =20 class Logout(APIView): diff --git a/mods/testing.py b/mods/testing.py index 58f9de7..2fd7d1e 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -517,6 +517,6 @@ class UntestView(APILoginRequiredView): =20 def handle(self, request, terms): se =3D SearchEngine() - q =3D se.search_series(*terms) + q =3D se.search_series(user=3Drequest.user, *terms) for s in q: _instance.clear_and_start_testing(s) diff --git a/www/views.py b/www/views.py index d7c60dd..1259a8e 100644 --- a/www/views.py +++ b/www/views.py @@ -224,7 +224,7 @@ def view_search(request): search =3D request.GET.get("q", "").strip() terms =3D [x.strip() for x in search.split(" ") if x] se =3D SearchEngine() - query =3D se.search_series(*terms) + query =3D se.search_series(user=3Drequest.user, *terms) return render_series_list_page(request, query, search=3Dsearch, project=3Dse.project(), keywords=3Dse.last_keywords()) --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 1538145956054894.9215155868582; Fri, 28 Sep 2018 07:45:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB27381DEC; Fri, 28 Sep 2018 14:45:54 +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 C9F705D777; Fri, 28 Sep 2018 14:45:54 +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 BADCE4BB74; Fri, 28 Sep 2018 14:45:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjri3024602 for ; Fri, 28 Sep 2018 10:45:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id A7FB62010D9A; Fri, 28 Sep 2018 14:45:53 +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 9E6572010D95 for ; Fri, 28 Sep 2018 14:45:53 +0000 (UTC) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 895A73082142 for ; Fri, 28 Sep 2018 14:45:52 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id o18-v6so2506907wmc.0 for ; Fri, 28 Sep 2018 07:45:52 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=q5eWrI2kWogtaVi3eEO9Xr1x553Cf4kdmeg90vAybrg=; b=kqs+RQSxndkk4PGVqLRJu+bVsRSZeRJq/CeEFufnxk3bxa06gZ9KE08G6oLObrFrRe 5vaKnq6/RhpuDUmLcwsGP/LI5k0J6HJ72Jf59XtlGqwlNwC7DFv0nFvWgpwb1FfKJ1Yj NJ9LvCqEdX9pnwm2HQ+NumPUe3wNZr/HsF81pQ1LjQs8QMehmizqcdUv7d2ddJH+AnvF ZII98Ih8OMX4yj0+mpWAg3an/lDpsiwBMRKHdRM5bNE2p+ELsMPYymGkMlzRGb3+PFGv gbjsu3SbpHjn7+Ifoou2A78i/D9duXbKP6vsMJH6YDeIeFKScUS/KYRNm3ZfWr1D9HWK zbPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=q5eWrI2kWogtaVi3eEO9Xr1x553Cf4kdmeg90vAybrg=; b=lAwbDLvS2EsFOwV8xFs4csVRXTBZnett2iuytNI4k9oWKHd9IQQ3k2s7k0HrFY3swX vyq7YUrWcnz+Kc4WepQSFto/7qH4jmoVJvkmhMo4TQ3h/bY1YQLAzWVVEwYe+akTnANJ DVKcFfnViTyFJXMP/mQApHznvJ1ejGeLUfUYsahuCUjpjLQA2fR1UL8edi2m7UDrqJwt bZdZBIJ2FWGQACIoPoZej5n3unVSGMqfouOSF7iFVtWbASEIBvwrXEAsHMn9kRAII+tz HTdWQfOQNsDinAemC/Gry9amnCdZkGMXAxCob+TGzqE3GlBJ+EgcESxqVCCp3apOjnAA 05Uw== X-Gm-Message-State: ABuFfohZehCEL8kAjr0UgQaSI+jVjzSfEcSV2/hGo0HOJY6wTencXJe1 NiCq42gaDdD/XGeyGLdg3at+oMr8cMY= X-Google-Smtp-Source: ACcGV63IWgvu9C5Kxj/LrLkigiaG8RO93P0gf1K35G0VyjXueYq11JNFeRSBCRhLvXcOUKEd6+sPsw== X-Received: by 2002:a1c:7711:: with SMTP id t17-v6mr2033922wmi.35.1538145950883; Fri, 28 Sep 2018 07:45:50 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:36 +0200 Message-Id: <20180928144537.5051-10-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 28 Sep 2018 14:45:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 28 Sep 2018 14:45:52 +0000 (UTC) for IP:'209.85.128.45' DOMAIN:'mail-wm1-f45.google.com' HELO:'mail-wm1-f45.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.45 mail-wm1-f45.google.com 209.85.128.45 mail-wm1-f45.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 09/10] www: add back extra_status to series detail 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 28 Sep 2018 14:45:54 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This will be used by the review links, which are not linked to a Result. Signed-off-by: Paolo Bonzini --- static/css/base.css | 4 ++-- www/templates/series-detail.html | 10 ++++++++-- www/views.py | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/static/css/base.css b/static/css/base.css index 545aad1..7fe45e4 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -137,10 +137,10 @@ h1, h2, h3, .h1, .h2, .h3 { .status-content > .fa { color: #337ab7; } -.status-content.status-failure > .fa { +.status-content > .fa-warning { color: #CC0000; } -.status-content.status-success > .fa { +.status-content > .fa-check { color: #009900; } .status-content > div { diff --git a/www/templates/series-detail.html b/www/templates/series-detail= .html index 52b8f96..cb5d611 100644 --- a/www/templates/series-detail.html +++ b/www/templates/series-detail.html @@ -51,13 +51,13 @@ =20
{% if series.num_patches < series.total_patches %} -
+
Only {{ series.num_patches }} patches received!
{% endif %} {% for result in results %} -
+
{% if result.status =3D=3D "pending" %} {% elif result.status =3D=3D "running" %} {% elif result.status =3D=3D "failure" %} @@ -65,6 +65,12 @@
{{ result.html }}
{% endfor %} +{% for status in series.extra_status %} +
+ {% if status.icon %}{% = endif %} +
{{ status.html }}
+
+{% endfor %} =20 {% if is_head %} {% if series.get_diff_stat %} diff --git a/www/views.py b/www/views.py index 1259a8e..dd910b1 100644 --- a/www/views.py +++ b/www/views.py @@ -52,6 +52,7 @@ def prepare_message(request, project, m, detailed): }) # hook points for plugins m.has_other_revisions =3D False + m.extra_status =3D [] m.extra_ops =3D [] m.extra_links =3D [] dispatch_module_hook("prepare_message_hook", request=3Drequest, messag= e=3Dm, --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Mar 28 23:22:02 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; 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 15381459587251017.1063266804089; Fri, 28 Sep 2018 07:45:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B5153082B24; Fri, 28 Sep 2018 14:45:57 +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 7E31AAFF3D; Fri, 28 Sep 2018 14:45:57 +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 6FAC7181A12F; Fri, 28 Sep 2018 14:45:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8SEjtY0024633 for ; Fri, 28 Sep 2018 10:45:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id E3E3E17272; Fri, 28 Sep 2018 14:45:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB97165968 for ; Fri, 28 Sep 2018 14:45:55 +0000 (UTC) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF423308FB8A for ; Fri, 28 Sep 2018 14:45:53 +0000 (UTC) Received: by mail-wm1-f48.google.com with SMTP id c14-v6so2495645wmb.4 for ; Fri, 28 Sep 2018 07:45:53 -0700 (PDT) Received: from donizetti.par1.mozilla.com ([2a00:8c40:243:232:de:fba5:535e:2dc2]) by smtp.gmail.com with ESMTPSA id n68-v6sm1884636wmn.5.2018.09.28.07.45.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 07:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=K2HBwyyI6bUNtuFFxYlncMZ07TamUunasI8QfwTMQNQ=; b=jgxdTR/za4YT5Pl9RtZZP4IH70Fx1Yab6IiekdzSY1QYDJin/Sb28ZXu7FJyZHzOG/ szviCb3SL2mNFWA+hyq7xQnbCeJY6koxwxz9/p+IvC5RznpehfHYlmfOkIA9OTQJT0MY aUaxgMHrMbfEDY7t6tf9NgzcrgFpkEbl6UjZReVmoHcgLdJ4yb6rs8jfzthQbhQ+KCpA 3htgbt+VF1ciQkAwl9GxaSQIX9HDvLivTVkmheNnKjXH42pNwHMZANFRm+FYUKk9VyXL coYh4gIUqtEAEaH8EGW93P3hKiSd24Ph61yk+E+YvdEb/ZA+BzuKyZ464vN8BRh9fXMC unzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=K2HBwyyI6bUNtuFFxYlncMZ07TamUunasI8QfwTMQNQ=; b=UjnkiCo+ng0c2HtE1bbX/qtxRKf9pFhjF7XsbxSjtlng/r7RvsqfporP3eWDjRHz3u yOAUqbmHkSxwyuiDfZtSPd6Q1qrS0hicuFD9Rh+u9kWtI2zLBs1rpX+rhDCJ2AJWo8YZ fTMoqoN1X8bqi3LfgmI94c34aR+ONezPuAnkbIttqfRz9tTvIiB7PGhoTOKSQiShlSbR knuct70ztgEvwIPum1nlLbhABiZuZ9BpfAZ9P64IDAuIjkAwn6U0k8oRzsgtu9zDnPlT WanNvrfr9YkYCV4tRfXTh8AeOCAi4vm5P4mShxRhLPHc19CN4JeLswAnKYjdxmO7nW6s fIeQ== X-Gm-Message-State: ABuFfoixvCGyYoYeurYMlfFhh/mA4PYmbpBEakYfJVHlGjY4dcnQ9FPf C80jf0jEwBlt/DNBb4k/wnxRVuY/KGc= X-Google-Smtp-Source: ACcGV63WiiBCIZ8wWWhFyAcc1Zk00lZf1pK/EL7MIRD/1V0qOFJEgKEZFrstCN+TJ7VhsIDvmXjxYg== X-Received: by 2002:a1c:5dd4:: with SMTP id r203-v6mr1935166wmb.29.1538145951899; Fri, 28 Sep 2018 07:45:51 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Fri, 28 Sep 2018 16:45:37 +0200 Message-Id: <20180928144537.5051-11-pbonzini@redhat.com> In-Reply-To: <20180928144537.5051-1-pbonzini@redhat.com> References: <20180928144537.5051-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 28 Sep 2018 14:45:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 28 Sep 2018 14:45:54 +0000 (UTC) for IP:'209.85.128.48' DOMAIN:'mail-wm1-f48.google.com' HELO:'mail-wm1-f48.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.489 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.128.48 mail-wm1-f48.google.com 209.85.128.48 mail-wm1-f48.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 10/10] add Review model 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.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 28 Sep 2018 14:45:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This model has a simple many-to-many relation with series, that lets logged-in users mark series as accepted or rejected, and use the status in a query. Three new search operators are added: ack (with synonyms accept and accepted), nack (with synonyms reject and rejected), review (with synonyms reviewed). Sample useful queries include the following: - "-is:merged ack:me" (what should I merge) - "to:pbonzini@redhat.com -is:merged -reviewed:me" (what should I review) - "nvme -is:merged -reviewed:fam" (what did Fam overlook :)) Signed-off-by: Paolo Bonzini --- api/migrations/0034_auto_20180822_1106.py | 32 ++++++++++ api/models.py | 7 +++ api/search.py | 33 +++++++++- mods/maintainer.py | 75 +++++++++++++++++++++-- static/css/base.css | 2 +- 5 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 api/migrations/0034_auto_20180822_1106.py diff --git a/api/migrations/0034_auto_20180822_1106.py b/api/migrations/003= 4_auto_20180822_1106.py new file mode 100644 index 0000000..d830d47 --- /dev/null +++ b/api/migrations/0034_auto_20180822_1106.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.13 on 2018-08-22 11:06 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies =3D [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('api', '0033_auto_20180803_0809'), + ] + + operations =3D [ + migrations.CreateModel( + name=3D'Review', + fields=3D[ + ('id', models.AutoField(auto_created=3DTrue, primary_key= =3DTrue, serialize=3DFalse, verbose_name=3D'ID')), + ('accept', models.BooleanField()), + ('message', models.ForeignKey(on_delete=3Ddjango.db.models= .deletion.CASCADE, to=3D'api.Message')), + ('user', models.ForeignKey(on_delete=3Ddjango.db.models.de= letion.CASCADE, to=3Dsettings.AUTH_USER_MODEL)), + ], + ), + migrations.AddField( + model_name=3D'message', + name=3D'reviews', + field=3Dmodels.ManyToManyField(blank=3DTrue, through=3D'api.Re= view', to=3Dsettings.AUTH_USER_MODEL), + ), + ] diff --git a/api/models.py b/api/models.py index 32e8b41..e4737cb 100644 --- a/api/models.py +++ b/api/models.py @@ -423,6 +423,11 @@ class MessageManager(models.Manager): def HeaderFieldModel(**args): return models.CharField(max_length=3D4096, **args) =20 +class Review(models.Model): + user =3D models.ForeignKey(User) + message =3D models.ForeignKey('Message') + accept =3D models.BooleanField() + class Message(models.Model): """ Patch email message """ =20 @@ -459,6 +464,8 @@ class Message(models.Model): # number of patches we've got if is_series_head num_patches =3D models.IntegerField(null=3DFalse, default=3D-1, blank= =3DTrue) =20 + reviews =3D models.ManyToManyField(User, blank=3DTrue, through=3DRevie= w) + objects =3D MessageManager() =20 def save_mbox(self, mbox_blob): diff --git a/api/search.py b/api/search.py index cf3c145..a218789 100644 --- a/api/search.py +++ b/api/search.py @@ -8,7 +8,7 @@ # This work is licensed under the MIT License. Please see the LICENSE fil= e or # http://opensource.org/licenses/MIT. =20 -from .models import Message, MessageProperty, MessageResult, Result +from .models import Message, MessageProperty, MessageResult, Result, Review from functools import reduce from django.db.models import Q =20 @@ -122,6 +122,18 @@ Example: =20 --- =20 +### Search by review state + +Syntax: + + - accept:USERNAME or ack:USERNAME - the series was marked as accepted by = the user + - reject:USERNAME or nack:USERNAME - the series was marked as reject by t= he user + - review:USERNAME - the series was marked as accepted or rejected by the = user + +USERNAME can be "me" to identify the current user + +--- + ### Reverse condition =20 - Syntax: !TERM @@ -219,6 +231,16 @@ Search text keyword in the email message. Example: return Q(is_merged=3DTrue) return None =20 + def _make_filter_review(self, username, user, **kwargs): + if username =3D=3D "me": + if not user.is_authenticated: + # Django hack to return an always false Q object + return Q(pk=3DNone) + q =3D Q(user=3Duser, **kwargs) + else: + q =3D Q(user__username=3Dusername, **kwargs) + return self._make_filter_subquery(Review, q) + def _make_filter(self, term, user): if term.startswith("age:"): cond =3D term[term.find(":") + 1:] @@ -260,6 +282,15 @@ Search text keyword in the email message. Example: return self._make_filter_result(term[8:], status=3DResult.PEND= ING) elif term.startswith("running:"): return self._make_filter_result(term[8:], status=3DResult.RUNN= ING) + elif term.startswith("ack:") or term.startswith("accept:") or term= .startswith("accepted:"): + username =3D term[term.find(":") + 1:] + return self._make_filter_review(username, user, accept=3DTrue) + elif term.startswith("nack:") or term.startswith("reject:") or ter= m.startswith("rejected:"): + username =3D term[term.find(":") + 1:] + return self._make_filter_review(username, user, accept=3DFalse) + elif term.startswith("review:") or term.startswith("reviewed:"): + username =3D term[term.find(":") + 1:] + return self._make_filter_review(username, user) elif term.startswith("project:"): cond =3D term[term.find(":") + 1:] self._projects.add(cond) diff --git a/mods/maintainer.py b/mods/maintainer.py index e25d8e2..d95ec4c 100644 --- a/mods/maintainer.py +++ b/mods/maintainer.py @@ -12,13 +12,31 @@ from django.conf.urls import url from django.http import Http404, HttpResponseRedirect from django.urls import reverse from mod import PatchewModule -from api.models import Message +from api.models import Message, Review =20 class MaintainerModule(PatchewModule): """ Project maintainer related tasks """ =20 name =3D "maintainer" =20 + def _update_review_state(self, request, message_id, accept): + if not request.user.is_authenticated: + return HttpResponseForbidden() + msg =3D Message.objects.find_series(message_id) + r =3D Review.objects.filter(user=3Drequest.user, message=3Dmsg) + r =3D r[0] if r else Review(user=3Drequest.user, message=3Dmsg) + r.accept =3D accept + r.save() + return HttpResponseRedirect(request.META.get('HTTP_REFERER')) + + def _delete_review(self, request, message_id): + if not request.user.is_authenticated: + return HttpResponseForbidden() + msg =3D Message.objects.find_series(message_id) + r =3D Review.objects.filter(user=3Drequest.user, message=3Dmsg) + r.delete() + return HttpResponseRedirect(request.META.get('HTTP_REFERER')) + def _update_merge_state(self, request, message_id, is_merged): s =3D Message.objects.find_series(message_id) if not s: @@ -35,6 +53,15 @@ class MaintainerModule(PatchewModule): def www_view_clear_merged(self, request, message_id): return self._update_merge_state(request, message_id, False) =20 + def www_view_mark_accepted(self, request, message_id): + return self._update_review_state(request, message_id, True) + + def www_view_mark_rejected(self, request, message_id): + return self._update_review_state(request, message_id, False) + + def www_view_clear_reviewed(self, request, message_id): + return self._delete_review(request, message_id) + def www_url_hook(self, urlpatterns): urlpatterns.append(url(r"^mark-as-merged/(?P.*)/", self.www_view_mark_as_merged, @@ -42,18 +69,58 @@ class MaintainerModule(PatchewModule): urlpatterns.append(url(r"^clear-merged/(?P.*)/", self.www_view_clear_merged, name=3D"clear-merged")) + urlpatterns.append(url(r"^mark-as-accepted/(?P.*)/", + self.www_view_mark_accepted, + name=3D"mark-as-accepted")) + urlpatterns.append(url(r"^mark-as-rejected/(?P.*)/", + self.www_view_mark_rejected, + name=3D"mark-as-rejected")) + urlpatterns.append(url(r"^clear-reviewed/(?P.*)/", + self.www_view_clear_reviewed, + name=3D"clear-reviewed")) =20 def prepare_message_hook(self, request, message, detailed): - if not detailed: + if not detailed or not request.user.is_authenticated: return - if message.is_series_head and request.user.is_authenticated: + if message.is_series_head: if message.is_merged: message.extra_ops.append({"url": reverse("clear-merged", kwargs=3D{"messag= e_id": message.message_id}), - "icon": "times", + "icon": "eraser", "title": "Clear merged state"}) else: message.extra_ops.append({"url": reverse("mark-as-merged", kwargs=3D{"messag= e_id": message.message_id}), "icon": "check", "title": "Mark series as merged"= }) + + r =3D Review.objects.filter(user=3Drequest.user, message=3Dmessage= ).first() + if r and r.accept: + message.extra_status.append({ + "icon": "fa-check", + "html": 'The series is marked for merging' + }) + else: + if message.is_series_head: + message.extra_ops.append({"url": reverse("mark-as-accepted= ", + kwargs=3D{"messag= e_id": message.message_id}), + "icon": "check", + "title": "Mark series as accepte= d"}) + + if r and not r.accept: + message.extra_status.append({ + "icon": "fa-times", + "html": 'The series is marked as rejected' + }) + else: + if message.is_series_head: + message.extra_ops.append({"url": reverse("mark-as-rejected= ", + kwargs=3D{"messag= e_id": message.message_id}), + "icon": "times", + "title": "Mark series as rejecte= d"}) + + if r: + message.extra_ops.append({"url": reverse("clear-reviewed", + kwargs=3D{"message_id= ": message.message_id}), + "icon": "eraser", + "title": "Clear review state"}) diff --git a/static/css/base.css b/static/css/base.css index 7fe45e4..9e04f50 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -137,7 +137,7 @@ h1, h2, h3, .h1, .h2, .h3 { .status-content > .fa { color: #337ab7; } -.status-content > .fa-warning { +.status-content > .fa-warning, .status-content > .fa-times { color: #CC0000; } .status-content > .fa-check { --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel