From bbc4eda39e7bda7f2f476aab75e16ccd4e91c01b Mon Sep 17 00:00:00 2001
From: Simon Zolin <s.zolin@adguard.com>
Date: Tue, 16 Jun 2020 12:10:17 +0300
Subject: [PATCH] If there are no more older entries, `"oldest":""` is
 returned.

---
 AGHTechDoc.md               | 2 ++
 querylog/querylog_search.go | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/AGHTechDoc.md b/AGHTechDoc.md
index b2f4ab73..ad9854d3 100644
--- a/AGHTechDoc.md
+++ b/AGHTechDoc.md
@@ -1302,6 +1302,8 @@ Response:
 
 The most recent entries are at the top of list.
 
+If there are no more older entries, `"oldest":""` is returned.
+
 
 ### API: Set querylog parameters
 
diff --git a/querylog/querylog_search.go b/querylog/querylog_search.go
index eda1f92d..afa8afc2 100644
--- a/querylog/querylog_search.go
+++ b/querylog/querylog_search.go
@@ -129,7 +129,9 @@ func (l *queryLog) searchFiles(params *searchParams) ([]*logEntry, time.Time, in
 		}
 	}
 
-	oldest = time.Unix(0, oldestNano)
+	if oldestNano != 0 {
+		oldest = time.Unix(0, oldestNano)
+	}
 	return entries, oldest, total
 }