Skip to content

Commit

Permalink
More efficient msg filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesturner246 committed Oct 21, 2024
1 parent f13cf94 commit cc4472e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions process_manager/views/partials.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,11 @@ def process_table(request: HttpRequest) -> HttpResponse:
@login_required
def messages(request: HttpRequest) -> HttpResponse:
"""Renders Kafka messages from the database."""
search = request.GET.get("search", "").lower()

messages = []
for msg in DruncMessage.objects.all():
# Filter messages based on search parameter.
if search not in msg.message.lower():
continue

# Filter messages based on search parameter.
search = request.GET.get("search", "")
for msg in DruncMessage.objects.filter(message__icontains=search):
# Time is stored as UTC. localtime(t) converts this to our configured timezone.
timestamp = localtime(msg.timestamp).strftime("%Y-%m-%d %H:%M:%S")

Expand Down

0 comments on commit cc4472e

Please sign in to comment.