From nobody Sat Dec 21 14:58:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663680369; cv=none; d=zohomail.com; s=zohoarc; b=FhepvcrLtoHlErQiyNed7DPwXmSrd4azisBHtf+HKwCi9oJokwzGRnJg0zikC/Ls+5Er/S8LRWP5+MwuV6XwqeKu7I40rEqeuHRxbkNZrYCh27lE4ltMl3N5CwTZ5t/hBCpkwdD7cBMyL6FXyZpQX3ooMQssxofqwMeES1jilzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663680369; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lu+62X/leU3gDir8m8TyapQk1+eP4QHs9XJhAXrf58k=; b=m7TICuJufz2OzQBpq47pk9PV2BQ9v2w1ZbP5Rw3tTvP3q9VBC1ub1Uj9xQMYaZrsOlASiuciQtI1KvfjBQn45+6jsF5NT62f6szT4hChJ5OsOyRFMtjlBKyfQeHvcyBjkkmgmxBBTQHumRh6ApCWpAKG7BjBs/St9PNo//hExqs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1663680369292465.75628525068373; Tue, 20 Sep 2022 06:26:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-Bej3yQ52Nh2Fcs1OfVOPoA-1; Tue, 20 Sep 2022 09:26:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E316E101A943; Tue, 20 Sep 2022 13:26:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB98B2028E98; Tue, 20 Sep 2022 13:26:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A78861946A46; Tue, 20 Sep 2022 13:26:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4215D1946588 for ; Tue, 20 Sep 2022 13:04:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0DB912024CC5; Tue, 20 Sep 2022 13:04:13 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 064482024CBF for ; Tue, 20 Sep 2022 13:04:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DABCA29AA2EF for ; Tue, 20 Sep 2022 13:04:12 +0000 (UTC) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-122-PTF71jgoM8C_WU-w2_zEOw-1; Tue, 20 Sep 2022 09:04:09 -0400 Received: by mail-ej1-f71.google.com with SMTP id qf40-20020a1709077f2800b0077b43f8b94cso1351763ejc.23 for ; Tue, 20 Sep 2022 06:04:09 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id g6-20020a170906538600b0077086d2db8esm829153ejo.140.2022.09.20.06.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663680368; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lu+62X/leU3gDir8m8TyapQk1+eP4QHs9XJhAXrf58k=; b=F+YOk/tW7ARuVonwAhaMt2UyVwaycp70848CoBfX3IKUBAXm/MiQEwhwVJz/qMG/k4n/4J UoeETjR1SEXti94WV35n2bJjVKlyB2lPDRuI2ebavHcbgojpirPGCtS1W+IiEfEfksgAVR QepBS7BYLG2uYpw+OaRsFKGLb+pzz6Y= X-MC-Unique: Bej3yQ52Nh2Fcs1OfVOPoA-1 X-Original-To: patchew-devel@listman.corp.redhat.com X-MC-Unique: PTF71jgoM8C_WU-w2_zEOw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=bm8BS1BVEZZgdgoZZwN+LvkaGASC9YuEE2Gcr6WK6GE=; b=LXQRLMWP26+FypJGGTiChiqBOWxIrqkXIVbXa3OsRc84XfI+Ca4UQwIE5V5Gt3CRK1 N06semLwtyo5xCXkjhxcX+5IRXew/w8PQaOhX5Gq7HrrnNTIL7IV42hOpefOTsikYria tOUp8Ez4kVc48C7utsLq4IAaPkl+uj1vybT9L4z6CPcPtyByMgzmuLkeRsz1EXIm35nF M6AQILoRQyB8i5wPruhy5xYnETMcAvRysAY8Yq1IdXl3Ghaqjq/+eQRV8sCBXa0rTKpj idKYRDVzDLIr6v0x7plOAl3w7svaHpcX8sB6YBlVFFrPbWsRHtYH1FMV1+dRvVRyiUmN d2TQ== X-Gm-Message-State: ACrzQf3sg3VuarXrzg+bRgBp1iRiMjTuaEvl6WCzTck/VXUUw6QFP0OB Z068UUn4SmKzfNNd78HPq3gSBA3f2j6DhQc9xj9ADR3RmxU7516KdQ6Ez93t0SYvUBszST8UKWZ FnLpq0jjx0eOawHn4QfgxH5nFTzjJrvyhfc2TboByUFdxk+Kacc1bcx/H3tQbvN9e/6zGw49J1w == X-Received: by 2002:a17:907:7f91:b0:77f:c4c7:9155 with SMTP id qk17-20020a1709077f9100b0077fc4c79155mr16737153ejc.476.1663679048123; Tue, 20 Sep 2022 06:04:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6P6/LP3DAQc3K6GKgECW2SzzHYzYCntriHjq6TowC6FbXyTGFgKkkVrjvlPwqT2YiLH7Wn7g== X-Received: by 2002:a17:907:7f91:b0:77f:c4c7:9155 with SMTP id qk17-20020a1709077f9100b0077fc4c79155mr16737118ejc.476.1663679047744; Tue, 20 Sep 2022 06:04:07 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Tue, 20 Sep 2022 15:04:01 +0200 Message-Id: <20220920130404.39806-2-pbonzini@redhat.com> In-Reply-To: <20220920130404.39806-1-pbonzini@redhat.com> References: <20220920130404.39806-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Subject: [Patchew-devel] [PATCH 1/4] models: add denormalized Project link to Result X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcaratti@redhat.com Errors-To: patchew-devel-bounces@redhat.com Sender: "Patchew-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663680370115100003 Content-Type: text/plain; charset="utf-8" This is needed to handle the series/unapplied queries efficiently. The ProjectResult.project field is generalized and moved to Result. Because the ProjectResult.project field will be removed, make it temporarily NULL so that the migration can work backwards and populate it from Result.project. Signed-off-by: Paolo Bonzini --- api/migrations/0066_auto_20220919_1004.py | 24 +++++++++++++++++++++++ api/models.py | 10 +++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 api/migrations/0066_auto_20220919_1004.py diff --git a/api/migrations/0066_auto_20220919_1004.py b/api/migrations/006= 6_auto_20220919_1004.py new file mode 100644 index 0000000..548481b --- /dev/null +++ b/api/migrations/0066_auto_20220919_1004.py @@ -0,0 +1,24 @@ +# Generated by Django 3.1.14 on 2022-09-19 10:04 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0065_auto_20220411_1153'), + ] + + operations =3D [ + migrations.AddField( + model_name=3D'result', + name=3D'project_denorm', + field=3Dmodels.ForeignKey(null=3DTrue, on_delete=3Ddjango.db.m= odels.deletion.CASCADE, related_name=3D'+', to=3D'api.project'), + ), + migrations.AlterField( + model_name=3D'projectresult', + name=3D'project', + field=3Dmodels.ForeignKey(null=3DTrue, on_delete=3Ddjango.db.m= odels.deletion.CASCADE, related_name=3D'results', to=3D'api.project'), + ), + ] diff --git a/api/models.py b/api/models.py index cd0285d..45c7f70 100644 --- a/api/models.py +++ b/api/models.py @@ -63,6 +63,10 @@ class Result(models.Model): log_entry =3D models.OneToOneField(LogEntry, on_delete=3Dmodels.CASCAD= E, null=3DTrue) data =3D jsonfield.JSONField(default=3D{}) =20 + project_denorm =3D models.ForeignKey( + "Project", related_name=3D"+", on_delete=3Dmodels.CASCADE, null=3D= True + ) + class Meta: index_together =3D [("status", "name")] =20 @@ -327,12 +331,12 @@ class Project(models.Model): return len(updated_series) =20 def create_result(self, **kwargs): - return ProjectResult(project=3Dself, **kwargs) + return ProjectResult(project=3Dself, project_denorm=3Dself, **kwar= gs) =20 =20 class ProjectResult(Result): project =3D models.ForeignKey( - Project, related_name=3D"results", on_delete=3Dmodels.CASCADE + Project, related_name=3D"results", on_delete=3Dmodels.CASCADE, nul= l=3DTrue ) =20 @property @@ -938,7 +942,7 @@ class Message(models.Model): emit_event("SeriesMerged", project=3Dself.project, series=3Dself) =20 def create_result(self, **kwargs): - return MessageResult(message=3Dself, **kwargs) + return MessageResult(message=3Dself, project_denorm=3Dself.project= , **kwargs) =20 def __str__(self): return self.project.name + "/" + self.subject --=20 2.37.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel From nobody Sat Dec 21 14:58:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663681181; cv=none; d=zohomail.com; s=zohoarc; b=dPjIFeXBDbg1pRvGnEsnn5ggT+tqaCCXO8Wez/x4mY4d+d2zU1O7xdVHaT2ZPuSKINkL3PZsacP8xsW8DBI0khDC/kgpB9zZJ7zneH9HPz409LjfKeVsc+gdoytAi65r/FHvd8JqdbSF5nOowkjp1uZybzu5Aiowgkhf+0te/FA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663681181; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nAXqrQWD0FeogBOofTPbz8ZpG48ZeYWs4zcTIWrIHyo=; b=KMqb4DlkrJJwmvtROffZCkYTWHRSwo6p61LkrFIZppoPuJuRAr4azc74ZOIHrIfPjVMACJkDKW0CWuLNhz+pe2GExRj1A/N/QDPvTbM0f56u1gYo4IEhPrgChnTaCNg57+TW1/MTLW6ioNhzgbytndzNlIpAMUlyoVe+YOEBYkc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1663681181209121.79937163636703; Tue, 20 Sep 2022 06:39:41 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-i8DddrN9No6b3zmzxOIFAw-1; Tue, 20 Sep 2022 09:39:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7E511C08962; Tue, 20 Sep 2022 13:39:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFC2E40C6EC2; Tue, 20 Sep 2022 13:39:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8E0B519465A0; Tue, 20 Sep 2022 13:39:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B69691946588 for ; Tue, 20 Sep 2022 13:04:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A8444492B05; Tue, 20 Sep 2022 13:04:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A119D492B04 for ; Tue, 20 Sep 2022 13:04:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AE601E68191 for ; Tue, 20 Sep 2022 13:04:16 +0000 (UTC) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-115-kBigYB0ONhe9JTreqmW9bA-1; Tue, 20 Sep 2022 09:04:12 -0400 Received: by mail-ej1-f71.google.com with SMTP id hp18-20020a1709073e1200b0078054727517so1372941ejc.0 for ; Tue, 20 Sep 2022 06:04:12 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id d6-20020a170906040600b00779dc23be62sm806586eja.120.2022.09.20.06.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663681180; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nAXqrQWD0FeogBOofTPbz8ZpG48ZeYWs4zcTIWrIHyo=; b=JhcxDs4Pci9AlhPBzAyMP98MG7j9LuqFrJ6I9BMFkmwx08Emz+bCPXOhC103pwojTWBjaH coQ+QHFwcrOYw6HtNmkBJe58aj2hxKCOJEHN2kpNjvg6j12YCfCwlE1WrpG7ZZp9+IZ3Zl os/UsDZA3DnbJcvr+I1KJNo1RTV8k10= X-MC-Unique: i8DddrN9No6b3zmzxOIFAw-1 X-Original-To: patchew-devel@listman.corp.redhat.com X-MC-Unique: kBigYB0ONhe9JTreqmW9bA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=d9hn503PdNfvpiHaykCqG7EeddCGyrDCH7qbemMuHS0=; b=bnTsIw8ZfQLlIRLZwSSV+fTkb8vwOK7AZbxA2RXEw2Gp63JFkbOtc/CHrfROSzuNuv Z0dr6Sszs7xxldplZQOPvWuhpPwm/AxL+dcKAzl+gDHC2IfH3JImSZ1/JBr883rkSmYI li5xDghh+SlVCPFB8YJA4x5VaqkkcJVdj6Bw80Oqtyw761G4pR83rxUNJ9MPUboEsBoj yVvE3bmxqwvVhutHIXmjNHJbBeHJboqmuKxiYbOthODOEfV3cPN3z7dHHT0pbU197Sim U3OLiG8RPl2s0BGiwrPWo3MrvjDCU3l30bmW69KE/ZButZ3oYuIasJ2JQJFEG5ifQPmC TAhQ== X-Gm-Message-State: ACrzQf2/8ApcYFzCLrlSQjcS8qBdHXHB5PnRk4ZJdJDp53uvSmMqgiYU e6Sezp38kEAeEszrMWlMWRc+ApeYhYtmC7I4EgS8OTNzgn7BI3USCzNONpFGSqtfwccpTI3J17l AQ1E8awK6wHhKI1IIZn6wZiO1bxZ6knbbW897iIX4nmPLO5xtzIU65XM59p09s0o+chD6lozNfA == X-Received: by 2002:a17:907:9729:b0:77c:3742:137a with SMTP id jg41-20020a170907972900b0077c3742137amr16687749ejc.630.1663679051031; Tue, 20 Sep 2022 06:04:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Ni+7bGoACzpIbNlQcDN0BLKY2d25rAcS0f3sberktwrqO6+lbaleBRcCdiZJne/7BQ84Kyw== X-Received: by 2002:a17:907:9729:b0:77c:3742:137a with SMTP id jg41-20020a170907972900b0077c3742137amr16687719ejc.630.1663679050653; Tue, 20 Sep 2022 06:04:10 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Tue, 20 Sep 2022 15:04:02 +0200 Message-Id: <20220920130404.39806-3-pbonzini@redhat.com> In-Reply-To: <20220920130404.39806-1-pbonzini@redhat.com> References: <20220920130404.39806-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Subject: [Patchew-devel] [PATCH 2/4] models: populate denormalized project field X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcaratti@redhat.com Errors-To: patchew-devel-bounces@redhat.com Sender: "Patchew-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663681182360100001 Content-Type: text/plain; charset="utf-8" The field is now populated and need not be nullable. Signed-off-by: Paolo Bonzini --- api/migrations/0067_result_denormalize.py | 32 +++++++++++++++++++++++ api/migrations/0068_auto_20220919_1007.py | 19 ++++++++++++++ api/models.py | 2 +- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 api/migrations/0067_result_denormalize.py create mode 100644 api/migrations/0068_auto_20220919_1007.py diff --git a/api/migrations/0067_result_denormalize.py b/api/migrations/006= 7_result_denormalize.py new file mode 100644 index 0000000..8394256 --- /dev/null +++ b/api/migrations/0067_result_denormalize.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations +from django.db.models import F, Subquery, OuterRef + + +def populate_denormalized_project(apps, schema_editor): + Message =3D apps.get_model("api", "Message") + MessageResult =3D apps.get_model("api", "MessageResult") + ProjectResult =3D apps.get_model("api", "ProjectResult") + ProjectResult.objects.filter(project_denorm__isnull=3DTrue).update( + project_denorm=3D + Subquery(ProjectResult.objects.filter(result_ptr_id=3DOuterRef= ('pk')).values('project')[:1])) + MessageResult.objects.filter(project_denorm__isnull=3DTrue).update( + project_denorm=3D + Subquery(MessageResult.objects.filter(result_ptr_id=3DOuterRef= ('pk')).values('message__project')[:1])) + + +def populate_projectresult_project(apps, schema_editor): + ProjectResult =3D apps.get_model("api", "ProjectResult") + ProjectResult.update(project=3DF('project_denorm')) + + +class Migration(migrations.Migration): + + dependencies =3D [("api", "0066_auto_20220919_1004")] + + operations =3D [ + migrations.RunPython(populate_denormalized_project, populate_proje= ctresult_project) + ] + diff --git a/api/migrations/0068_auto_20220919_1007.py b/api/migrations/006= 8_auto_20220919_1007.py new file mode 100644 index 0000000..6e070a4 --- /dev/null +++ b/api/migrations/0068_auto_20220919_1007.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.14 on 2022-09-19 10:07 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0067_result_denormalize'), + ] + + operations =3D [ + migrations.AlterField( + model_name=3D'result', + name=3D'project_denorm', + field=3Dmodels.ForeignKey(on_delete=3Ddjango.db.models.deletio= n.CASCADE, related_name=3D'+', to=3D'api.project'), + ), + ] diff --git a/api/models.py b/api/models.py index 45c7f70..0728853 100644 --- a/api/models.py +++ b/api/models.py @@ -64,7 +64,7 @@ class Result(models.Model): data =3D jsonfield.JSONField(default=3D{}) =20 project_denorm =3D models.ForeignKey( - "Project", related_name=3D"+", on_delete=3Dmodels.CASCADE, null=3D= True + "Project", related_name=3D"+", on_delete=3Dmodels.CASCADE ) =20 class Meta: --=20 2.37.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel From nobody Sat Dec 21 14:58:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663680219; cv=none; d=zohomail.com; s=zohoarc; b=m/B9EpGagiLVEmDCQAWliwe/aV0tl0/r4xJ3qQsYTXOvBGyi6mMjvKnV5zOzpzdSjj6KW3zZoVsR8KNrlKPpmuj3ZEZ01D6lvQ7AN14/SmWvIzWxbF5r9CiXCkTcp8xn7FSAG9OsxtwSzC7pCV0H3Omr5GJpmV+zvLAn/OZWjuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663680219; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mInoPWG/nsWdakMiuyj4D928yC9zleY6vTcl3T6PrjI=; b=JXx/byj/FQlrxkMXliT/W5X+AAO4PwvfkgmtGwiv258CaxD11Q4uG1lkajkli03/sppiLbhOIWtCVC1icvq/pBXoUWi7FkV/Xe55Ct5P11JrK5thpWm+G9rnszeue3jmkXMSnA78dEoGIMptWLZHtrrewpg7aarPQWawwE++r6U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1663680219864783.6985633828153; Tue, 20 Sep 2022 06:23:39 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-491-ZompRtKcPzi71q8CVHW7iw-1; Tue, 20 Sep 2022 09:23:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 41D2C2823811; Tue, 20 Sep 2022 13:23:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A81C112C070; Tue, 20 Sep 2022 13:23:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 14A271946A4E; Tue, 20 Sep 2022 13:23:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BE1BF1946588 for ; Tue, 20 Sep 2022 13:04:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B31BF400EA8E; Tue, 20 Sep 2022 13:04:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 81DE9400E88C for ; Tue, 20 Sep 2022 13:04:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6806E29AB45D for ; Tue, 20 Sep 2022 13:04:15 +0000 (UTC) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-586-wMTuiWE9MX-Tgpl0K-fsng-1; Tue, 20 Sep 2022 09:04:14 -0400 Received: by mail-ej1-f72.google.com with SMTP id hp18-20020a1709073e1200b0078054727517so1373005ejc.0 for ; Tue, 20 Sep 2022 06:04:13 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id h1-20020a1709070b0100b0073c74bee6eesm804349ejl.201.2022.09.20.06.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663680218; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mInoPWG/nsWdakMiuyj4D928yC9zleY6vTcl3T6PrjI=; b=JlCXOuuO8aFIrJRRr2BtVACYL4yWzLLLKiSPyCTBaRJC96fBQW5mgVSZW1pGw6ej53fPgZ O5E2njOKiD2bE5f21yuarPxYJLKGJVOho0PZ9fbJz0vK125TE06ICQyM3NITex4pLNKJVI kU2XO7dEOtW0LYWziowjg11LQqnBGnc= X-MC-Unique: ZompRtKcPzi71q8CVHW7iw-1 X-Original-To: patchew-devel@listman.corp.redhat.com X-MC-Unique: wMTuiWE9MX-Tgpl0K-fsng-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=DtssEbxu13v/sqK7iMn0E5eja5TMoMTAaIq4sypSvIc=; b=JeZ/53O8tO3ukFwMDRxq8y7IP2W6PO8V8BT8DdsLCpNKi4B4UKLqXz1q2tKYUMtklc Fu6HNgJIUShhu6HQ6Dfn0kXAwUzZWuucm5jvTDLIV6havzzK6k8WWOAo/BcGkVAef7mw Q2hCrpBHe67VO3q6O3wyH1k0aK9JZW2VcIna/ozTdy1EwvigUFpkRpbj8febpjdAL1nx RjLVVoYYeFdy/OHT7s7QYgMCs3+mKXb/CBy5CBdxIqv3xDZsFdma4nB+deKTXnBZ2QaE uPQAow6IGr28I0m6L7s0JPo15ADIiWzFGroPZb96ChVutz0Az+vKcwP0s2E3JJksHfYj h7+g== X-Gm-Message-State: ACrzQf1q+3xzGUgw0X6VFLrUpIsHwUs34pudaDonDFNiWxw/X3aQtzS2 qCZ99racZzvZQq/whNOQPckutpQbi9XTGfwYx4Eh6Cgz+oUenoaPUE1S0R5ZLzScR++aceTfGvx Q9UWJx7sIi0KNQOU+RRVeWbxzZR80wGIgPr2vUH+DSgZESGy7QfJeSCLGGUkyMuTN2iGLysH86g == X-Received: by 2002:a05:6402:2b8b:b0:43a:5475:f1ae with SMTP id fj11-20020a0564022b8b00b0043a5475f1aemr19867943edb.363.1663679052660; Tue, 20 Sep 2022 06:04:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Z8Xz9g/9MbwbrgP9VB6Eb3neZnjqaF9DkvWJPSACerFaIS4xy+e8gmn262vFeHyUvg9e+RQ== X-Received: by 2002:a05:6402:2b8b:b0:43a:5475:f1ae with SMTP id fj11-20020a0564022b8b00b0043a5475f1aemr19867912edb.363.1663679052393; Tue, 20 Sep 2022 06:04:12 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Tue, 20 Sep 2022 15:04:03 +0200 Message-Id: <20220920130404.39806-4-pbonzini@redhat.com> In-Reply-To: <20220920130404.39806-1-pbonzini@redhat.com> References: <20220920130404.39806-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Subject: [Patchew-devel] [PATCH 3/4] models: final step in introducing Result.project field X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcaratti@redhat.com Errors-To: patchew-devel-bounces@redhat.com Sender: "Patchew-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663680220812100001 Content-Type: text/plain; charset="utf-8" Remove the pre-existing field in ProjectResult and rename the new field from project_denorm to project. Signed-off-by: Paolo Bonzini --- api/migrations/0069_auto_20220919_1008.py | 22 ++++++++++++++++++++++ api/models.py | 20 +++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 api/migrations/0069_auto_20220919_1008.py diff --git a/api/migrations/0069_auto_20220919_1008.py b/api/migrations/006= 9_auto_20220919_1008.py new file mode 100644 index 0000000..dbd4ccc --- /dev/null +++ b/api/migrations/0069_auto_20220919_1008.py @@ -0,0 +1,22 @@ +# Generated by Django 3.1.14 on 2022-09-19 10:08 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0068_auto_20220919_1007'), + ] + + operations =3D [ + migrations.RemoveField( + model_name=3D'projectresult', + name=3D'project', + ), + migrations.RenameField( + model_name=3D'result', + old_name=3D'project_denorm', + new_name=3D'project', + ), + ] diff --git a/api/models.py b/api/models.py index 0728853..b942e20 100644 --- a/api/models.py +++ b/api/models.py @@ -63,7 +63,8 @@ class Result(models.Model): log_entry =3D models.OneToOneField(LogEntry, on_delete=3Dmodels.CASCAD= E, null=3DTrue) data =3D jsonfield.JSONField(default=3D{}) =20 - project_denorm =3D models.ForeignKey( + # This field is denormalized in the case of MessageResult + project =3D models.ForeignKey( "Project", related_name=3D"+", on_delete=3Dmodels.CASCADE ) =20 @@ -331,14 +332,19 @@ class Project(models.Model): return len(updated_series) =20 def create_result(self, **kwargs): - return ProjectResult(project=3Dself, project_denorm=3Dself, **kwar= gs) + return ProjectResult(project=3Dself, **kwargs) + + # Because Result's project field is used also for MessageResults (in w= hich + # case it is a denormalized form of Message.project), it does not have + # a related_name; it would not make sense to return the MessageResults + # too. Instead, this property returns a queryset of ProjectResults for + # this project. + @property + def results(self): + return ProjectResult.objects.filter(project=3Dself) =20 =20 class ProjectResult(Result): - project =3D models.ForeignKey( - Project, related_name=3D"results", on_delete=3Dmodels.CASCADE, nul= l=3DTrue - ) - @property def obj(self): return self.project @@ -942,7 +948,7 @@ class Message(models.Model): emit_event("SeriesMerged", project=3Dself.project, series=3Dself) =20 def create_result(self, **kwargs): - return MessageResult(message=3Dself, project_denorm=3Dself.project= , **kwargs) + return MessageResult(message=3Dself, project=3Dself.project, **kwa= rgs) =20 def __str__(self): return self.project.name + "/" + self.subject --=20 2.37.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel From nobody Sat Dec 21 14:58:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663680073; cv=none; d=zohomail.com; s=zohoarc; b=kma/Jo833l1vqkIXmodsr1dV2iJrKkO4esC6vgbOeqTKcumZQSpjWGWnd0YfQ0OClgb6PwHckf91sBpqNv7ekRGNIaqd+PRd1D5nnHnZOUUnVakI6gcRaH82FTHQTaPU80n04I7nEQi24ps01MPWR4DCsh4D733AZvVpba1mu1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663680073; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mb442VZC36WKF9yfNI1gwe/wfIdNySNbIO0Zk1ah3JA=; b=IS3y5zoEPe6yBR8bCyY1sAz1Jb+oj2oUxd2wr9W09m6TXo2nGvnH8Ah8h+Zd8v4RtywG3EHIrhKV3pMZAv489jFOyvdtemNT+XaoyP+aYquoyrWQ+63HCCxcX+qyjHl+mN+lQLdsigBB2oWatOdHqCA2VV5A2+OOIURKKlSBlg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1663680073435125.91398971321837; Tue, 20 Sep 2022 06:21:13 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-370-_rxSo0LRNMuzLA1p-OJxlA-1; Tue, 20 Sep 2022 09:21:09 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7EF318E0A6C; Tue, 20 Sep 2022 13:21:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D030A492B1B; Tue, 20 Sep 2022 13:21:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BE5DD19465A0; Tue, 20 Sep 2022 13:21:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E0BB51946588 for ; Tue, 20 Sep 2022 13:04:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C3E8840E80EA; Tue, 20 Sep 2022 13:04:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD81240E80E7 for ; Tue, 20 Sep 2022 13:04:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FF3087B2A8 for ; Tue, 20 Sep 2022 13:04:18 +0000 (UTC) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-591-9jZ0KH-QOWyiLmYHndWLcg-1; Tue, 20 Sep 2022 09:04:17 -0400 Received: by mail-ej1-f72.google.com with SMTP id xj11-20020a170906db0b00b0077b6ecb23fcso1348600ejb.5 for ; Tue, 20 Sep 2022 06:04:16 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id v13-20020aa7dbcd000000b004548dfb895asm465992edt.34.2022.09.20.06.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663680072; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mb442VZC36WKF9yfNI1gwe/wfIdNySNbIO0Zk1ah3JA=; b=ekavdxVBuwt5F1reRcto0b8tEHTHHRYSejn36P3QlxTo6sN1ynZg0hTdFvAr1KN8eDQkAE UDWkguJS3xvdzYBYzfSQUS4xTPZKpo6i1b72LXmgs/St2p9HOAX+MUWqKY9F585oLJaccx 7GZDnvoIX4mJvSAZTWWfDKbS8EDrFBo= X-MC-Unique: _rxSo0LRNMuzLA1p-OJxlA-1 X-Original-To: patchew-devel@listman.corp.redhat.com X-MC-Unique: 9jZ0KH-QOWyiLmYHndWLcg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=H0cGop/9y9EnrPEWh+kpeWwioDA854IgyiZr0Hf+ZVw=; b=6TgZGjYMJsY3PSDs5ltnVqiF1DW07kJJEqEjSRVz51VMVlnkAWIP9VF4Xyqttn2w/C OA7ZhRMbdt12OkV42J0ipEiOLuThQDFJGzU0CYYM4akDDl5HZi856FLeXz9oJrRidPnD bQpAnmSVPg0CgJqhdJDbHVQ2cZsTdHF4KyS6uL1HUNez5oxCawt9jBJYKsT4m8MQWc1G E1ZTq1g/Syuv0TTEx9s1QzCcEnXenSiAKpbLxI5veqlXn/e1F3TAwCbJTqsEdkrMBTqQ pVLmlN674cF820n1LfI1dCFQcLp86C8AnRKQV4G99FRYzBwsDX1pSNlGSfdAFJYgxMVX l4tA== X-Gm-Message-State: ACrzQf29ScYOKRTkllXqd7SasA46Th1TO0/Jh67HqJMpRbjzdzKdHXNK tR6wNqTH2JpWW4+fr573IzKouydKQURj2wRDTc38JbJZsp1ZUTzY291a37bpKAD+Z+/JYS756Si Y9Ba6AXrulYynjLcbC77PS+vWOUAvAx9t9X4dBRt5n83e87eSu1S2DooexM2eySrX43mjTEhlNQ == X-Received: by 2002:a17:907:3f87:b0:781:ee94:7f91 with SMTP id hr7-20020a1709073f8700b00781ee947f91mr145592ejc.52.1663679055613; Tue, 20 Sep 2022 06:04:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7wtWpPXUcX7D36wFw9NaPv1EinQkpn7D16w1V2asGFA5JqrLbfzF4og/W3l0RF+EAC/HHhAA== X-Received: by 2002:a17:907:3f87:b0:781:ee94:7f91 with SMTP id hr7-20020a1709073f8700b00781ee947f91mr145560ejc.52.1663679055208; Tue, 20 Sep 2022 06:04:15 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Tue, 20 Sep 2022 15:04:04 +0200 Message-Id: <20220920130404.39806-5-pbonzini@redhat.com> In-Reply-To: <20220920130404.39806-1-pbonzini@redhat.com> References: <20220920130404.39806-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Subject: [Patchew-devel] [PATCH 4/4] git: use denormalized project to query unapplied messages X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dcaratti@redhat.com Errors-To: patchew-devel-bounces@redhat.com Sender: "Patchew-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663680075330100001 Content-Type: text/plain; charset="utf-8" In order to find unapplied MessageResults for a given set of projects, the database would have to walk all the messages for the project and jump from Message to MessageResult to Result. For efficiency, look up the project, name ("git") and status ("pending") in a single index. Signed-off-by: Paolo Bonzini --- api/migrations/0070_auto_20220919_1016.py | 17 +++++++++++++++++ api/models.py | 2 +- mods/git.py | 6 ++---- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 api/migrations/0070_auto_20220919_1016.py diff --git a/api/migrations/0070_auto_20220919_1016.py b/api/migrations/007= 0_auto_20220919_1016.py new file mode 100644 index 0000000..5ea23c1 --- /dev/null +++ b/api/migrations/0070_auto_20220919_1016.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.14 on 2022-09-19 10:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0069_auto_20220919_1008'), + ] + + operations =3D [ + migrations.AlterIndexTogether( + name=3D'result', + index_together=3D{('status', 'name', 'project')}, + ), + ] diff --git a/api/models.py b/api/models.py index b942e20..b1b42c1 100644 --- a/api/models.py +++ b/api/models.py @@ -69,7 +69,7 @@ class Result(models.Model): ) =20 class Meta: - index_together =3D [("status", "name")] + index_together =3D [("status", "name", "project")] =20 def is_success(self): return self.status =3D=3D self.SUCCESS diff --git a/mods/git.py b/mods/git.py index 5b3dddc..8220d5d 100644 --- a/mods/git.py +++ b/mods/git.py @@ -283,8 +283,6 @@ class GitModule(PatchewModule): ) =20 def pending_series(self, target_repo): - q =3D Message.objects.filter(results__name=3D"git", results__statu= s=3D"pending") - # Postgres could use JSON fields instead. Fortunately projects are # few so this is cheap def match_target_repo(config, target_repo): @@ -302,8 +300,8 @@ class GitModule(PatchewModule): projects =3D [ pid for pid, config in projects if match_target_repo(config, t= arget_repo) ] - q =3D q.filter(project__pk__in=3Dprojects) - return q + return Message.objects.filter(results__name=3D"git", results__stat= us=3D"pending", + results__project__pk__in=3Dprojects) =20 =20 class UnappliedSeriesSerializer(SeriesSerializer): --=20 2.37.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel