From nobody Tue May 13 19:50:13 2025 Delivered-To: importer2@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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1555604525; cv=none; d=zoho.com; s=zohoarc; b=FcFXFYeYfKsYSdY6i9FPkukfZ32z5dkmFtTcN5G2BRcCWeJStSUrVLCOkFda7vxHvfq4wBfNn+ceU0W1gHTPe+7DCfkZSyeGdpCjaDplTAFA6Xx0rVpJ1fjkbCHRa1dXuZ52RzVz+TDQeiedSr0DZMUmp37/cifPsrK+KsrJkus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555604525; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=vqy9sJCsQIih9yWfzJPk7D72KUnnxQkUC1pPv8R1HaU=; b=Npng/X/MTShJL1ICd+HdY3jdYMYqRqiY2eReRhYkFBE7nVKTiSjGW/supbicLd1fVIyap8pGiLozt/FAbTySS0azAoXBw/SnPbqfw0lj0EA0AQdl0CLvzaeYBaS8VKjxaWzNxchv9cLoWOqbWjT2LjY1l0wuiQE2BiZS3dh7/Lw= ARC-Authentication-Results: i=1; mx.zoho.com; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1555604525975564.6141376273549; Thu, 18 Apr 2019 09:22:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C33E413A82; Thu, 18 Apr 2019 16:22:03 +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 B8E265D705; Thu, 18 Apr 2019 16:22:03 +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 AD0054EA71; Thu, 18 Apr 2019 16:22:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3IGM2hj009222 for ; Thu, 18 Apr 2019 12:22:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3EE7460BF7; Thu, 18 Apr 2019 16:22:02 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-46.ams2.redhat.com [10.36.112.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B54360BFC for ; Thu, 18 Apr 2019 16:22:00 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 18 Apr 2019 18:21:44 +0200 Message-Id: <20190418162146.5695-9-pbonzini@redhat.com> In-Reply-To: <20190418162146.5695-1-pbonzini@redhat.com> References: <20190418162146.5695-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 08/10] models: add property fields to Message 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Apr 2019 16:22:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is the first step towards storing properties in a single JSON dictionary, which is simpler now that properties are fewer and smaller than they used to be. The related name "properties" has to be freed up for the new field. --- api/migrations/0051_auto_20190418_1346.py | 33 +++++++++++++++++++++++ api/models.py | 9 ++++--- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 api/migrations/0051_auto_20190418_1346.py diff --git a/api/migrations/0051_auto_20190418_1346.py b/api/migrations/005= 1_auto_20190418_1346.py new file mode 100644 index 0000000..7d57a34 --- /dev/null +++ b/api/migrations/0051_auto_20190418_1346.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-04-18 13:46 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import jsonfield.encoder +import jsonfield.fields + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0050_populate_project_config'), + ] + + operations =3D [ + migrations.AddField( + model_name=3D'message', + name=3D'properties', + field=3Djsonfield.fields.JSONField(default=3D{}, dump_kwargs= =3D{'cls': jsonfield.encoder.JSONEncoder, 'separators': (',', ':')}, load_k= wargs=3D{}), + ), + migrations.AddField( + model_name=3D'project', + name=3D'properties', + field=3Djsonfield.fields.JSONField(default=3D{}, dump_kwargs= =3D{'cls': jsonfield.encoder.JSONEncoder, 'separators': (',', ':')}, load_k= wargs=3D{}), + ), + migrations.AlterField( + model_name=3D'messageproperty', + name=3D'message', + field=3Dmodels.ForeignKey(on_delete=3Ddjango.db.models.deletio= n.CASCADE, to=3D'api.Message'), + ), + ] diff --git a/api/models.py b/api/models.py index 512bf50..7c3aefb 100644 --- a/api/models.py +++ b/api/models.py @@ -172,6 +172,7 @@ class Project(models.Model): "parent_project=3DNULL")) maintainers =3D models.ManyToManyField(User, blank=3DTrue) config =3D jsonfield.JSONField(default=3D{}) + properties =3D jsonfield.JSONField(default=3D{}) =20 def __str__(self): return self.name @@ -348,7 +349,7 @@ class MessageManager(models.Manager): return None else: q =3D super(MessageManager, self).get_queryset() - return q.filter(is_series_head=3DTrue).prefetch_related('propertie= s', 'project') + return q.filter(is_series_head=3DTrue).prefetch_related('messagepr= operty_set', 'project') =20 def find_series(self, message_id, project_name=3DNone): heads =3D self.series_heads(project_name) @@ -510,6 +511,7 @@ class Message(models.Model): =20 maintainers =3D jsonfield.JSONField(blank=3DTrue, default=3D[]) flags =3D models.CharField(max_length=3D64, blank=3DTrue, default=3D"") + properties =3D jsonfield.JSONField(default=3D{}) =20 def save_mbox(self, mbox_blob): save_blob(mbox_blob, self.message_id) @@ -621,7 +623,7 @@ class Message(models.Model): # The prefetch cache is invalidated, query again all_props =3D MessageProperty.objects.filter(message=3Dsel= f) else: - all_props =3D self.properties.all() + all_props =3D self.messageproperty_set.all() r =3D {} for m in all_props: r[m.name] =3D m.value @@ -783,8 +785,7 @@ class MessageResult(Result): =20 =20 class MessageProperty(models.Model): - message =3D models.ForeignKey('Message', on_delete=3Dmodels.CASCADE, - related_name=3D'properties') + message =3D models.ForeignKey('Message', on_delete=3Dmodels.CASCADE) name =3D models.CharField(max_length=3D256) value =3D jsonfield.JSONField() =20 --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel