From nobody Fri Mar 29 10:33:22 2024 Delivered-To: importer@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; dkim=fail; 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=1556795902; cv=none; d=zoho.com; s=zohoarc; b=DX3n3MtI7Xr5XanPlwcI56D7jsLZvR26bpu2AGGPg8TGbTc2m/ou+2DUeiYxFSwQj9mixU6iQYbU2hytj3FQ9V2jN9SOzTbVs3nG0sDxYMA07UGW26Or4Ev8Q35XoXZB96AMwYePCtvU7Gmg6hnVPZnZWangyik4CytP1fINqu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795902; 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=bGh5KrosHph3MKW+opo3hxM7eDHgluaRco1OLIvQ+7M=; b=f0380STDf9DVDhBvNM7a6WNSiljJRpXD+jm3FN9EYc3JOaV5X9n7KmK1Kjf2rgwDIaBghlPb2XzTYq0hTsBfOBO0byw7XO9gKSpd9IcMB13B1I/dAAuYifHryL3r5YdwnnaXGs5+lJ7xQLDHVQ5EBwyBopRt3q0ZaOe0Krkg/6I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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 1556795902744395.60835618163264; Thu, 2 May 2019 04:18:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7AAC230832C5; Thu, 2 May 2019 11:18:21 +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 6F7358A28C; Thu, 2 May 2019 11:18:21 +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 65CF13FB11; Thu, 2 May 2019 11:18:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIKEJ009042 for ; Thu, 2 May 2019 07:18:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79E2B174B1; Thu, 2 May 2019 11:18:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7508B39C1 for ; Thu, 2 May 2019 11:18:20 +0000 (UTC) Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A34458E5B for ; Thu, 2 May 2019 11:18:19 +0000 (UTC) Received: by mail-ot1-f43.google.com with SMTP id g8so1673662otl.8 for ; Thu, 02 May 2019 04:18:19 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=azltHbjV6kMSIPRJsnyQGJjkiCVDaHNsK6YIB/QINv0=; b=L5vHhz/nCed9rgXlUiLHHXYfM03UQr3Sue8rtebOke+6T1a3rLjRmh7SAvc3VYPhTt 8XtHC2xGHhZxxz86PdjYK/Ut6fmze0b/145TC9dW6sHomuRtb2j6HFFcjuOzIO6n3K6e khD1rfn9w+qHHZcJa/32eGcdoLQ4wN4Eq/DomSPmigfehlcAAtL3ZUH80WIOHyY+aIUA y1CBgb0BK3neDFo4ObtxSMb6aIKIVSLovan61hU87lscSMBWP8SzjM0717FyMy/0oNgv nhl4Ax1cGphOXLdR6YH7UHkAEUrzSSpxgYKGdfH7SWpAW0PQTLP+Z6sGS/giqULi/Sa8 MSjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=azltHbjV6kMSIPRJsnyQGJjkiCVDaHNsK6YIB/QINv0=; b=ryFpDkLfCGEQqJPEdrzXJFh9IPEjB9BA9IOgK3Y1zSYcxuB+B77/Is5l7JxPpvm6Ud ZdIQQDlmPRztG8imkKQbU9HFluszhTymGAF3PK8BJ8xhlMzSFNciW7ayh3UJEMV9la3T R/oepSS2xwC8uWJfgh0ppl/OB2xDgQZlm0I7sQePUibONs0iwuTzqKEDZAd+msrc4vJv rpCAdVrX+8XKywjdGKh33WBoplzz0f6mO2FXTXGYGEmMfXri1WZqpjWSTHROtzS1fty1 08+lxUOJtlOSUVuNd06jrECWqTYwWPVkhsZdp1Z/mp0duVReyl18Kd9f2BeAxEzuIZXW Euxg== X-Gm-Message-State: APjAAAVxDYaPqV9WJ/nqrqDzCiSNP6h+k02075SqgmveB/soh7JJyF7z QqFpLY0iTabaL6ScN8SPnx46UISI1gY= X-Google-Smtp-Source: APXvYqxJZo02Jv4DCOECbA93NyW9ycJ3sRROgHNz3gdt0bzmzuhbQ2WJbrGg7yXQNV3lsxEUgA+w0A== X-Received: by 2002:a9d:6a06:: with SMTP id g6mr213377otn.169.1556795898769; Thu, 02 May 2019 04:18:18 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:18:02 -0600 Message-Id: <20190502111804.15843-16-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 02 May 2019 11:18:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 02 May 2019 11:18:19 +0000 (UTC) for IP:'209.85.210.43' DOMAIN:'mail-ot1-f43.google.com' HELO:'mail-ot1-f43.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.125 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.210.43 mail-ot1-f43.google.com 209.85.210.43 mail-ot1-f43.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 15/17] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 02 May 2019 11:18:21 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) 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..623da0f --- /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_message_flags_postgres_fts'), + ] + + 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 67d1ed5..dd385ad 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 @@ -358,7 +359,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) @@ -520,6 +521,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) @@ -631,7 +633,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 @@ -793,8 +795,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