Applied, thank you.

I fixed up a small pep8 issue along the way.

Regards,
Daniel

Jeremy Kerr <j...@ozlabs.org> writes:

> It's possible that an EmailConfirmation object will have no associated
> user (eg, for email opt-out, which does not require a user object). In
> this case, we will see a NULL value for EmailConfirmation.user_id.
>
> However, having a NULL value appear in a SQL 'IN' clause will match
> every value. This means that once one of these null-user
> EmailConfirmations is present, we will never expire any non-active user
> accounts.
>
> This change adds a filter for a valid user_id when we query for active
> EmailConfirmation objects. This means we'll have a valid values set to
> use in the pending_confs set.
>
> Signed-off-by: Jeremy Kerr <j...@ozlabs.org>
> ---
>  patchwork/notifications.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/patchwork/notifications.py b/patchwork/notifications.py
> index a5f6423..571cff7 100644
> --- a/patchwork/notifications.py
> +++ b/patchwork/notifications.py
> @@ -109,7 +109,8 @@ def expire_notifications():
>      EmailConfirmation.objects.filter(q).delete()
>  
>      # remove inactive users with no pending confirmation
> -    pending_confs = EmailConfirmation.objects.values('user')
> +    pending_confs = (EmailConfirmation.objects
> +                        .filter(user__isnull=False).values('user'))
>      users = 
> User.objects.filter(is_active=False).exclude(id__in=pending_confs)
>  
>      # delete users
> -- 
> 2.17.1
>
> _______________________________________________
> Patchwork mailing list
> Patchwork@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
_______________________________________________
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to