From nobody Fri Apr 26 14:56:57 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