From nobody Sat Apr 27 00:22:17 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 206.53.239.180 is neither permitted nor denied by domain of freelists.org) client-ip=206.53.239.180; envelope-from=patchew-devel-bounce@freelists.org; helo=turing.freelists.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=none (zoho.com: 206.53.239.180 is neither permitted nor denied by domain of freelists.org) smtp.mailfrom=patchew-devel-bounce@freelists.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from turing.freelists.org (turing.freelists.org [206.53.239.180]) by mx.zohomail.com with SMTPS id 1519827452945642.0032750793637; Wed, 28 Feb 2018 06:17:32 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id EF17F2A7F1; Wed, 28 Feb 2018 09:17:27 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k3TWhxm34qGR; Wed, 28 Feb 2018 09:17:27 -0500 (EST) Received: from turing.freelists.org (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id A3BDF28FB0; Wed, 28 Feb 2018 09:17:27 -0500 (EST) Received: with ECARTIS (v1.0.0; list patchew-devel); Wed, 28 Feb 2018 09:17:27 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 5E2942A7F1 for ; Wed, 28 Feb 2018 09:17:27 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uc7BuvKaKXEl for ; Wed, 28 Feb 2018 09:17:27 -0500 (EST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id E62BD28FB0 for ; Wed, 28 Feb 2018 09:17:26 -0500 (EST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6D49402677E for ; Wed, 28 Feb 2018 14:17:25 +0000 (UTC) Received: from donizetti.redhat.com (unknown [10.36.118.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBA3C1C725; Wed, 28 Feb 2018 14:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freelists.org; s=turing; t=1519827447; bh=AhMBZ/QQFdRMuUBQAf3InbzqJQvliwduIDLcL/B4azQ=; h=From:To:Cc:Subject:Date:Reply-To:List-help:List-unsubscribe: List-Id:List-subscribe:List-owner:List-post:List-archive; b=hhrIAhgqCC74MZ0xi1s08s+6be1k9XkMvCoAE/WMgjolpproWuFeXk4Cmt5QzcQsX 6fL+fJKyDQGRj2OLasg0ELJVnBFXbCUrtTsDTTayzKj/7jNnsEd1O+fmawWgD6zu92 leXp/is3VDo1CI2+FifHndlHTTbmizuejGe7FyG4= X-Virus-Scanned: Debian amavisd-new at turing.freelists.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freelists.org; s=turing; t=1519827447; bh=AhMBZ/QQFdRMuUBQAf3InbzqJQvliwduIDLcL/B4azQ=; h=From:To:Cc:Subject:Date:Reply-To:List-help:List-unsubscribe: List-Id:List-subscribe:List-owner:List-post:List-archive; b=hhrIAhgqCC74MZ0xi1s08s+6be1k9XkMvCoAE/WMgjolpproWuFeXk4Cmt5QzcQsX 6fL+fJKyDQGRj2OLasg0ELJVnBFXbCUrtTsDTTayzKj/7jNnsEd1O+fmawWgD6zu92 leXp/is3VDo1CI2+FifHndlHTTbmizuejGe7FyG4= X-Original-To: patchew-devel@freelists.org X-Virus-Scanned: Debian amavisd-new at turing.freelists.org From: Paolo Bonzini To: patchew-devel@freelists.org Cc: famz@redhat.com Subject: [patchew-devel] [PATCH] diff: fix reply indicator Date: Wed, 28 Feb 2018 15:17:20 +0100 Message-Id: <20180228141720.7523-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 28 Feb 2018 14:17:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 28 Feb 2018 14:17:25 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-archive-position: 57 X-ecartis-version: Ecartis v1.0.0 Sender: patchew-devel-bounce@freelists.org Errors-to: patchew-devel-bounce@freelists.org X-original-sender: pbonzini@redhat.com Precedence: normal Reply-To: patchew-devel@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: patchew-devel X-List-ID: patchew-devel List-subscribe: List-owner: List-post: List-archive: X-list: patchew-devel X-ZohoMail-DKIM: pass (identity @freelists.org) X-ZohoMail: RDKM_0 RSF_4 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The reply indicator for individual messages was always empty, and the reply indicator for the cover letter showed comments for the entire series. (This happened to be correct for the two cases I used for testing...). Use an EXISTS subquery just like the series view does to fix it. Signed-off-by: Paolo Bonzini --- I've applied this patch. mods/diff.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/mods/diff.py b/mods/diff.py index d1b30af..eb8dfb8 100644 --- a/mods/diff.py +++ b/mods/diff.py @@ -17,6 +17,7 @@ from django.http import Http404 from django.urls import reverse from django.utils.html import format_html from django.utils.safestring import mark_safe +from django.db.models import Exists, OuterRef from mod import PatchewModule from api.models import Project, Message from api.rest import PluginMethodField @@ -76,7 +77,7 @@ class DiffModule(PatchewModule): html =3D html + format_html(' v{}', url, v) message.extra_links.append({"html": mark_safe(html), "icon": "exch= ange" }) =20 - def _get_series_for_diff(self, s): + def _get_series_for_diff(self, q): def _get_message_data(m): filtered =3D "" sep =3D "" @@ -92,21 +93,28 @@ class DiffModule(PatchewModule): return PatchInfo( subject=3Dm.subject, link=3Dm.get_message_view_url(), - has_replies=3Dm.last_comment_date is not None, + has_replies=3Dm.has_replies, body=3Dfiltered) =20 + def _add_has_replies(q, **kwargs): + replies =3D Message.objects.filter(in_reply_to=3DOuterRef('mes= sage_id'), **kwargs) + return q.annotate(has_replies=3DExists(replies)) + + q =3D _add_has_replies(q, is_patch=3DFalse) + s =3D q.first() + ret =3D list() + data =3D _get_message_data(s) + ret.append(data) if not s.is_patch: - data =3D _get_message_data(s) - ret.append(data) - for p in s.get_patches(): - data =3D _get_message_data(p) - ret.append(data) + for p in _add_has_replies(s.get_patches()): + data =3D _get_message_data(p) + ret.append(data) return ret =20 def www_view_series_diff(self, request, project, series_left, series_r= ight): - sl =3D Message.objects.filter(project__name=3Dproject, message_id= =3Dseries_left).first() - sr =3D Message.objects.filter(project__name=3Dproject, message_id= =3Dseries_right).first() + sl =3D Message.objects.filter(project__name=3Dproject, message_id= =3Dseries_left) + sr =3D Message.objects.filter(project__name=3Dproject, message_id= =3Dseries_right) return render_page(request, "series-diff.html", series_left=3Dself._get_series_for_diff(sl), series_right=3Dself._get_series_for_diff(sr)) --=20 2.14.3