On Wed, 05/02 17:27, Paolo Bonzini wrote:
> For a single request to http://127.0.0.1:8000/QEMU/ we get 78
> SQL queries, and 50 of them are checking whether the project is
> maintained by the current logged in user. Certainly caching the
> answer is a possibility, but really an anonymous user is never
> going to be a maintainer. Adding the check to maintained_by
> cuts the queries from 78 to 28 and the processing time from
> 12 to 7 ms.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> api/models.py | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/api/models.py b/api/models.py
> index 4cc2b74..504f2c7 100644
> --- a/api/models.py
> +++ b/api/models.py
> @@ -131,6 +131,8 @@ class Project(models.Model):
> return Message.objects.series_heads(project=self.name).count()
>
> def maintained_by(self, user):
> + if user.is_anonymous:
> + return False
> if user.is_superuser:
> return True
> if self.maintainers.filter(id=user.id).exists():
Applied, thanks!
Fam
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel