Change result count & history

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2025-10-02 17:02:49 +02:00
parent 4274c275b0
commit 9e4725a960
5 changed files with 31 additions and 49 deletions

View File

@@ -51,29 +51,13 @@ func routes(s *server.Server, cache *map[string]*search.Result, searchQueue chan
})
s.Router.GET("/history", func(c *gin.Context) {
type historyItem struct {
Id string
Status string
Date time.Time
Query search.Query
Results int
}
var history []historyItem
var history []search.Result
s.Mu.RLock()
for _, r := range *cache {
resultsCount := 0
if r.LeakResult.Rows != nil {
resultsCount = len(r.LeakResult.Rows)
}
history = append(history, historyItem{
Id: r.Id,
Status: r.Status,
Date: r.Date,
Query: r.Query,
Results: resultsCount,
})
history = append(history, *r)
}
s.Mu.RUnlock()
// Sort by date (newest first)
for i := 0; i < len(history)-1; i++ {
for j := 0; j < len(history)-i-1; j++ {
if history[j].Date.Before(history[j+1].Date) {

View File

@@ -27,8 +27,9 @@ type Query struct {
type Result struct {
Id string
Date time.Time
Status string // "queued", "pending", "completed"
Status string // "queued", "pending", "completed", "error"
Query Query
ResultsCount int // Total number of results found across all services
LeakResult dataleak.LeakResult
GithubResult osint.GithubResult
@@ -40,6 +41,7 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
mu.Lock()
r.Status = "pending"
r.ResultsCount = 0
mu.Unlock()
wg.Add(3)
@@ -54,6 +56,7 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
leakResult := dataleak.Search(s, q.Text, q.Column, q.ExactMatch)
mu.Lock()
r.LeakResult = leakResult
r.ResultsCount += len(leakResult.Rows)
mu.Unlock()
wg.Done()
}()
@@ -89,6 +92,15 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
}
mu.Lock()
r.GithubResult = githubResult
if githubResult.EmailResult != nil && githubResult.EmailResult.Commits != nil {
r.ResultsCount += len(githubResult.EmailResult.Commits)
}
if githubResult.EmailResult != nil && githubResult.EmailResult.Spoofing != nil && githubResult.EmailResult.Spoofing.Username != "" {
r.ResultsCount += 1
}
if githubResult.UsernameResult != nil && githubResult.UsernameResult.Commits != nil {
r.ResultsCount += len(githubResult.UsernameResult.Commits)
}
mu.Unlock()
wg.Done()
}()
@@ -104,6 +116,9 @@ func Search(s *server.Server, q Query, r *Result, mu *sync.RWMutex) {
gravatarResult := osint.GravatarSearch(s, cleanQueryText)
mu.Lock()
r.GravatarResult = gravatarResult
if gravatarResult.Results != nil {
r.ResultsCount += len(gravatarResult.Results)
}
mu.Unlock()
wg.Done()
}()

View File

@@ -82,13 +82,14 @@
{item.Query.Text}
</button>
</th>
<td>{item.Results}</td>
<td>{item.ResultsCount}</td>
<td
><div
class="badge badge-xs"
class:badge-success={item.Status === "completed"}
class:badge-warning={item.Status === "pending"}
class:badge-neutral={item.Status === "queued"}
class:badge-error={item.Status === "error"}
>
{item.Status}
</div></td

View File

@@ -4,18 +4,6 @@
import { BadgeInfo, Clock, File } from "@lucide/svelte";
const { result }: { result: Result } = $props();
let nresult = $state(0);
$effect(() => {
const r = [
result.LeakResult.Rows?.length | 0,
result.GithubResult.EmailResult?.Commits?.length | 0,
result.GithubResult.EmailResult?.Spoofing ? 1 : 0,
result.GithubResult.UsernameResult?.Commits?.length | 0,
result.GravatarResult.Results?.length | 0,
];
nresult = r.reduce((a, b) => a + b, 0);
});
</script>
<div class="stats stats-vertical md:stats-horizontal">
@@ -25,7 +13,7 @@
</div>
<div class="stat-title">Results</div>
<div class="stat-value" class:animate-pulse={result.Status === "pending"}>
{nresult.toLocaleString("fr")}
{result.ResultsCount.toLocaleString("fr")}
{#if result.Status === "pending"}
<span class="loading loading-dots loading-xs ml-2"></span>
{/if}
@@ -49,9 +37,9 @@
{#if result.Status === "pending"}
Pending
<span class="loading loading-dots loading-xs ml-2"></span>
{:else if result.Status === "completed" && nresult === 0}
{:else if result.Status === "completed" && result.ResultsCount === 0}
No results
{:else if result.Status === "completed" && nresult > 0}
{:else if result.Status === "completed"}
Completed
{:else}
{result.Status}

View File

@@ -36,23 +36,17 @@ export type GravatarResult = {
export type Result = {
Id: string;
Status: "queued" | "pending" | "completed";
Status: "queued" | "pending" | "completed" | "error";
Date: string;
Query: Query;
ResultsCount: number;
LeakResult: LeakResult;
GithubResult: GithubResult;
GravatarResult: GravatarResult;
};
export type HistoryItem = {
Id: string;
Status: "queued" | "pending" | "completed";
Date: string;
Query: Query;
Results: number;
};
export type History = HistoryItem[];
export type History = Result[];
export type ServerSettings = {
Folders: string[];