From nobody Tue May 13 15:31:41 2025 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 1535054467411191.0828829170182; Thu, 23 Aug 2018 13:01:07 -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 D2CFC30001E0; Thu, 23 Aug 2018 20:01:05 +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 C0CDB7F65D; Thu, 23 Aug 2018 20:01:05 +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 AEF3F4A464; Thu, 23 Aug 2018 20:01:05 +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 w7NK14AH027512 for ; Thu, 23 Aug 2018 16:01:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF5442010D5D; Thu, 23 Aug 2018 20:01:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D51BE2010D16 for ; Thu, 23 Aug 2018 20:01:02 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (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 5B3453086271 for ; Thu, 23 Aug 2018 20:01:01 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id k5-v6so5602213wre.10 for ; Thu, 23 Aug 2018 13:01:01 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v5-v6sm4330793wru.60.2018.08.23.13.00.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 13:00:59 -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=D6BTIjS7smfHtn7PMwdxcsUdj+6DrUUZne/tzCeH6Cw=; b=W8O0FasxjDXsaalvCXaHI8lkGBPRvZXQ6FD1Aruhka9w33hC6eEmgck8DOG6Ecf7tR ybnBOroexVtSZPxMURsY7DnZV255n2FceVaAaRCAqt3PmHJcZU67IwZGHyIJpjEcgMvD /0IcgYWkmwVsWEgVsxtjW8VJaDYKUJ4RaECKeG5FOPlk1fE8bVZiAS1N9dKtP97y6fRZ R3hWHTYF8LsOg6peYn1gk7Qb0n1r+0wER8VkNFdaND5OPZxuaB1TzH01HBor9tSPYele YQoCCxQ24YGczKOSqt6C+5mdTD3x93OGQO809/hz7qaxnxa7op091xmVKxQmMnsP7qDK KjHw== 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=D6BTIjS7smfHtn7PMwdxcsUdj+6DrUUZne/tzCeH6Cw=; b=LhK06Rgr/gdKTHOCqRK/i1m6LXho0FV81yr7IPva3O/soNynenIoCyhbKfxsaCHNNk MszJZ9rnNR1KXYG4P3ugkg4rIEm5vANbl7m4D5AC1pwFMRWlPE/QME9VxWI8zYkeQ3qN 9FXC98ND/olLo95qdQ7O1UIIqIidGXJtv8xtxpH1jtFaHLk8kmoKaKc9JlNPal/7Kf7r ZquO0hZi5HdrWzp8O30iY+ETzb/Z6tJV7qOHqsBcUeQdyGCD/yMCEGXYgB0H//EueGJK HANjDolmbLTxjn58ubsn1wUTR7neGcmZ0NG7ow8UfoB/rv+EWWcjNViMolLHWgFWTv26 +naA== X-Gm-Message-State: APzg51ByfZL5ROY0vpjCiRbnw8adOZqitVc4QWzRHvmhh0ATY70RZE8v JsXXu6S8e/eJgUFTdwTV0LtiDnas X-Google-Smtp-Source: ANB0VdbJwLxZNgueQLAUXYYYWEk4gTbjgmluSMkr3SAyphNkZCyTDUem98YLZpzeyv0Y3QhSJLJaiQ== X-Received: by 2002:a5d:53cf:: with SMTP id a15-v6mr13654595wrw.151.1535054459617; Thu, 23 Aug 2018 13:00:59 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 23 Aug 2018 22:00:52 +0200 Message-Id: <20180823200055.2389-4-pbonzini@redhat.com> In-Reply-To: <20180823200055.2389-1-pbonzini@redhat.com> References: <20180823200055.2389-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 23 Aug 2018 20:01:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 23 Aug 2018 20:01:01 +0000 (UTC) for IP:'209.85.221.65' DOMAIN:'mail-wr1-f65.google.com' HELO:'mail-wr1-f65.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.24 (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.65 mail-wr1-f65.google.com 209.85.221.65 mail-wr1-f65.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 3/6] 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.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.46]); Thu, 23 Aug 2018 20:01:05 +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 | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/api/search.py b/api/search.py index fd30ee5..7e11da4 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): @@ -89,6 +89,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 @@ -184,6 +199,9 @@ Search text keyword in the email message. Example: return Q(is_merged=3DTrue) return None =20 + def _make_filter_result(self, term, **kwargs): + return Q(results__name=3Dterm, **kwargs) | Q(results__name__starts= with=3Dterm+'.', **kwargs) + def _make_filter(self, term): if term.startswith("age:"): cond =3D term[term.find(":") + 1:] @@ -214,6 +232,14 @@ 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:], results__status=3DRe= sult.FAILURE) + elif term.startswith("success:"): + return self._make_filter_result(term[8:], results__status=3DRe= sult.SUCCESS) + elif term.startswith("pending:"): + return self._make_filter_result(term[8:], results__status=3DRe= sult.PENDING) + elif term.startswith("running:"): + return self._make_filter_result(term[8:], results__status=3DRe= sult.RUNNING) 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