From patchwork Tue Oct 30 21:56:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 991119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42l51J5358z9sCm for ; Wed, 31 Oct 2018 08:57:40 +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" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="hPFhoQjv"; 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 42l51J3XjwzF1Pl for ; Wed, 31 Oct 2018 08:57:40 +1100 (AEDT) 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" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="hPFhoQjv"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.15; helo=relay015.mxrelay.co; 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" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="hPFhoQjv"; dkim-atps=neutral Received: from relay015.mxrelay.co (relay015.mxrelay.co [185.234.75.15]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42l51B6LjNzDrYZ for ; Wed, 31 Oct 2018 08:57:34 +1100 (AEDT) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay015.mxrelay.co (Postfix) with ESMTP id A1C5A42CDF for ; Tue, 30 Oct 2018 21:57:00 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 7D6493F3DB for ; Tue, 30 Oct 2018 21:57:00 +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: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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RtdfcLHvK2MA+5kQOOS6Y3q+Pek4aiPtFDAbAFamGcU=; b=hPFhoQjvvoNJjRSisj+ZzoZ+qZ 86LrudjWGVsViQudKYaFUVoQ4oBMZZTIun5oulMUrUsKhcfilZgW2+P+RLtbahJiP5pnadf25wtkl DY0ffzjkrg2ySogM+AE73/LZD2cWASkf9V+PkRMvXu8PsoXRhhOz22T5Qmci9Z6fYoLwmyxo4acmH nRIn4L3he9gvkL1Fim9O0R/hgOEeTQ2XU4ocmvYsjYegG18sHF5vBp3Q59GfF6fu1bh73fEDO1pHX R5tWoY3g7t48K3Hej3IpIVIraolf+AuVwmrb7+zNDGKcRYYlyRjuaXyEMYGbEtHzwV/Bqiyb5Ckaf pGXjVfvQ==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH] parser: Use 'objects.create' instead of 'save' Date: Tue, 30 Oct 2018 21:56:55 +0000 Message-Id: <20181030215655.9223-1-stephen@that.guru> X-Mailer: git-send-email 2.19.1 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" As noted in the Django documentation [1], this lets us do things in one step. [1] https://docs.djangoproject.com/en/dev/topics/db/queries/#creating-objects Signed-off-by: Stephen Finucane Acked-by: Daniel Axtens --- patchwork/parser.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/patchwork/parser.py b/patchwork/parser.py index 6b7189cb..d6fa8437 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -1034,12 +1034,12 @@ def parse_mail(mail, list_id=None): # - there is an existing series, but it already has a patch with this # number in it if not series or Patch.objects.filter(series=series, number=x).count(): - series = Series(project=project, - date=date, - submitter=author, - version=version, - total=n) - series.save() + series = Series.objects.create( + project=project, + date=date, + submitter=author, + version=version, + total=n) # NOTE(stephenfin) We must save references for series. We # do this to handle the case where a later patch is @@ -1109,12 +1109,12 @@ def parse_mail(mail, list_id=None): msgid=msgid, series__project=project).first().series if not series: - series = Series(project=project, - date=date, - submitter=author, - version=version, - total=n) - series.save() + series = Series.objects.create( + project=project, + date=date, + submitter=author, + version=version, + total=n) # we don't save the in-reply-to or references fields # for a cover letter, as they can't refer to the same