Message ID | 20181030215655.9223-1-stephen@that.guru |
---|---|
State | Accepted |
Headers | show |
Series | parser: Use 'objects.create' instead of 'save' | expand |
Acked-by: Daniel Axtens <dja@axtens.net> Stephen Finucane <stephen@that.guru> writes: > 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 <stephen@that.guru> > --- > 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 > -- > 2.19.1 > > _______________________________________________ > Patchwork mailing list > Patchwork@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/patchwork
On Wed, 2018-10-31 at 10:33 +1100, Daniel Axtens wrote: > Acked-by: Daniel Axtens <dja@axtens.net> Thanks. Applied. > Stephen Finucane <stephen@that.guru> writes: > > > 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 <stephen@that.guru> > > --- > > 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 > > -- > > 2.19.1 > > > > _______________________________________________ > > Patchwork mailing list > > Patchwork@lists.ozlabs.org > > https://lists.ozlabs.org/listinfo/patchwork
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
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 <stephen@that.guru> --- patchwork/parser.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)