From patchwork Wed Mar 4 11:54:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 1248974 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48XXSs0xJWz9sQt for ; Wed, 4 Mar 2020 22:58:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=default header.b=akjkc/e8; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48XXSr415XzDqYt for ; Wed, 4 Mar 2020 22:58:04 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=that.guru (client-ip=172.82.139.220; helo=qrelay220.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=default header.b=akjkc/e8; dkim-atps=neutral Received: from qrelay220.mxroute.com (qrelay220.mxroute.com [172.82.139.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48XXPc0r2XzDqT2 for ; Wed, 4 Mar 2020 22:55:15 +1100 (AEDT) Received: from filter003.mxroute.com ([168.235.111.26] 168-235-111-26.cloud.ramnode.com) (Authenticated sender: mN4UYu2MZsgR) by qrelay220.mxroute.com (ZoneMTA) with ESMTPA id 170a5664435000f8af.002 for ; Wed, 04 Mar 2020 11:55:07 +0000 X-Zone-Loop: 32a2f6aa7fb1c5d4c25442ed0306c9f845a25e1cb101 X-Originating-IP: [168.235.111.26] Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter003.mxroute.com (Postfix) with ESMTPS id 115716003F; Wed, 4 Mar 2020 11:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9FmeoMKdSwhreWwiiPzDIjSXVDlUFpBP9AHiu/TjdbY=; b=akjkc/e8qPNmk/eI5xYvjpaxo3 bTohR7RgOt+lD/YNq+t0XdUOuWdLp8coPcgdrWmespXwdFvRFrbIQxvWPQksR1vYjbTtM1YBZC/rk Twbp45uo1MxxvzRfVKrxiT9ucCWNUODHtwzDdwSVq0SinWWjXqX9mcQUezBkr8STA9o9+KY2GJawi HdqZSth+hBZV4a/FofprGAFXhCea0LHBPFPxY9J5y3weWpvEGT2isQUDWGwJ/OuJHlaPzk6eeaKhW tTjS784iA8ZcLGp4ySKEcxIauqsh1NV1UJ+Zh+jhU851tykvTvBZ8itaBvnY9JRvdSHp6N+qRhv+U GdsDuoLg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 3/5] Revert "Be sensible computing project patch counts" Date: Wed, 4 Mar 2020 11:54:55 +0000 Message-Id: <20200304115457.32300-4-stephen@that.guru> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200304115457.32300-1-stephen@that.guru> References: <20200304115457.32300-1-stephen@that.guru> MIME-Version: 1.0 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This reverts commit cfcf2f2a80ac0709f1a5fd9aa212c8403daa5a18. This will no longer be necessary once we remove the Patch-Submission split. Revert it now to avoid needing to rejig this later. Conflicts: patchwork/views/project.py NOTE(stephenfin): Conflicts are due to commit 880ec8c5 ("Fetch maintainer information in one query") which changed nearby lines. Signed-off-by: Stephen Finucane Cc: Daniel Axtens Reviewed-by: Andrew Donnellan --- patchwork/views/project.py | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/patchwork/views/project.py b/patchwork/views/project.py index 8fa41794..4c25f715 100644 --- a/patchwork/views/project.py +++ b/patchwork/views/project.py @@ -10,10 +10,9 @@ from django.shortcuts import get_object_or_404 from django.shortcuts import render from django.urls import reverse +from patchwork.models import Patch from patchwork.models import Project -from django.db import connection - def project_list(request): projects = Project.objects.all() @@ -31,34 +30,14 @@ def project_list(request): def project_detail(request, project_id): project = get_object_or_404(Project, linkname=project_id) - - # So, we revert to raw sql because if we do what you'd think would - # be the correct thing in Django-ese, it ends up doing a *pointless* - # join with patchwork_submissions that ends up ruining the query. - # So, we do not do this, as this is wrong: - # - # patches = Patch.objects.filter( - # patch_project_id=project.id).only('archived') - # patches = patches.annotate(c=Count('archived')) - # - # and instead do this, because it's simple and fast - - n_patches = {} - with connection.cursor() as cursor: - cursor.execute('SELECT archived,COUNT(submission_ptr_id) as c ' - 'FROM patchwork_patch ' - 'WHERE patch_project_id=%s GROUP BY archived', - [project.id]) - - for r in cursor: - n_patches[r[0]] = r[1] + patches = Patch.objects.filter(project=project) context = { 'project': project, 'maintainers': User.objects.filter( profile__maintainer_projects=project).select_related('profile'), - 'n_patches': n_patches[False] if False in n_patches else 0, - 'n_archived_patches': n_patches[True] if True in n_patches else 0, + 'n_patches': patches.filter(archived=False).count(), + 'n_archived_patches': patches.filter(archived=True).count(), 'enable_xmlrpc': settings.ENABLE_XMLRPC, } return render(request, 'patchwork/project.html', context)