From 84a722eabcad706616f1de893a587ee032d86281 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Mon, 24 Oct 2022 19:31:53 +0200 Subject: [PATCH] Optimize the query --- core/admin/mailu/internal/views/rspamd.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/admin/mailu/internal/views/rspamd.py b/core/admin/mailu/internal/views/rspamd.py index e2e453ad..b6ead86b 100644 --- a/core/admin/mailu/internal/views/rspamd.py +++ b/core/admin/mailu/internal/views/rspamd.py @@ -28,5 +28,4 @@ def rspamd_dkim_key(domain_name): @internal.route("/rspamd/local_domains", methods=['GET']) def rspamd_local_domains(): - domains = set(models.Domain.query.all() + models.Alternative.query.all()) - return '\n'.join(map(str,domains)) + return '\n'.join(domain[0] for domain in models.Domain.query.with_entities(models.Domain.name).all() + models.Alternative.query.with_entities(models.Alternative.name).all())