Improve database queries

This commit is contained in:
2026-02-05 22:05:40 +01:00
parent e6339eae61
commit d780572d71
2 changed files with 2 additions and 2 deletions

View File

@@ -22,7 +22,7 @@ def cleanup_expired(app, start_time=None):
now = now_utc()
expired_count = 0
for hostname in Hostname.select().join(User).where(
for hostname in Hostname.select(Hostname, User.email).join(User).where(
(Hostname.expiry_ttl != 0) &
((Hostname.last_ipv4.is_null(False) & Hostname.last_ipv4_update.is_null(False)) |
(Hostname.last_ipv6.is_null(False) & Hostname.last_ipv6_update.is_null(False)))):

View File

@@ -134,7 +134,7 @@ def cmd_user_email(args, app):
def cmd_hostname_list(args, app):
"""List hostnames."""
query = Hostname.select().join(User)
query = Hostname.select(Hostname, User.username).join(User)
if args.user:
try: