Check if the result limit has been hit
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -10,8 +10,6 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: We need to know when we hit the LIMIT
|
|
||||||
|
|
||||||
func routes(s *server.Server, cache *map[string]*search.Result) {
|
func routes(s *server.Server, cache *map[string]*search.Result) {
|
||||||
s.Router.Use(
|
s.Router.Use(
|
||||||
func(c *gin.Context) {
|
func(c *gin.Context) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type LeakResult struct {
|
|||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
Rows []map[string]string
|
Rows []map[string]string
|
||||||
Error string
|
Error string
|
||||||
|
LimitHit bool // Whether the search hit the limit
|
||||||
}
|
}
|
||||||
|
|
||||||
func Search(s *server.Server, queryText, column string, exactMatch bool) LeakResult {
|
func Search(s *server.Server, queryText, column string, exactMatch bool) LeakResult {
|
||||||
@@ -76,6 +77,10 @@ func Search(s *server.Server, queryText, column string, exactMatch bool) LeakRes
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(result.Rows) >= s.Settings.Limit {
|
||||||
|
result.LimitHit = true
|
||||||
|
}
|
||||||
|
|
||||||
result.Rows = removeDuplicateMaps(result.Rows)
|
result.Rows = removeDuplicateMaps(result.Rows)
|
||||||
|
|
||||||
result.Duration = time.Since(now)
|
result.Duration = time.Since(now)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ type LeakResult = {
|
|||||||
Duration: number;
|
Duration: number;
|
||||||
Error: string;
|
Error: string;
|
||||||
Rows: Array<Record<string, string>>;
|
Rows: Array<Record<string, string>>;
|
||||||
|
LimitHit: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type GithubResult = {
|
type GithubResult = {
|
||||||
|
|||||||
@@ -170,6 +170,15 @@
|
|||||||
result.LeakResult.Duration,
|
result.LeakResult.Duration,
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
{#if result.LeakResult.LimitHit}
|
||||||
|
<div role="alert" class="alert alert-soft my-4">
|
||||||
|
<CircleAlert size={20} />
|
||||||
|
<div>
|
||||||
|
<span class="font-semibold">Limit hit!</span> Consider refining
|
||||||
|
your search query for more specific results.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<Rows {result} />
|
<Rows {result} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user