Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display seconds a query took to run #201

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/pkappa2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ func main() {
Stream *index.Stream
Tags []string
}
Elapsed int64
Offset uint
MoreResults bool
}{
Expand All @@ -543,6 +544,7 @@ func main() {
Tags []string
}{},
}
start := time.Now()
v := mgr.GetView()
defer v.Release()
hasMore, offset, err := v.SearchStreams(r.Context(), qq, func(c manager.StreamContext) error {
Expand All @@ -563,6 +565,7 @@ func main() {
http.Error(w, fmt.Sprintf("SearchStreams failed: %v", err), http.StatusInternalServerError)
return
}
response.Elapsed = time.Since(start).Microseconds()
response.MoreResults = hasMore
response.Offset = offset
w.Header().Set("Content-Type", "application/json")
Expand Down
1 change: 1 addition & 0 deletions web/src/apiClient.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function isSearchResult(obj: unknown): obj is SearchResult {
typeof e === "string"
)
) &&
typeof typedObj["Elapsed"] === "number" &&
typeof typedObj["Offset"] === "number" &&
typeof typedObj["MoreResults"] === "boolean"
)
Expand Down
1 change: 1 addition & 0 deletions web/src/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type Error = {
export type SearchResult = {
Debug: string[];
Results: Result[];
Elapsed: number;
Offset: number;
MoreResults: boolean;
};
Expand Down
6 changes: 6 additions & 0 deletions web/src/components/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
>Results might be outdated.</v-alert
>
<v-spacer />
<div v-if="streams.result">
<span class="text-caption">
Query took {{ (streams.result.Elapsed / 1_000_000).toFixed(6) }}s
</span>
</div>
<v-spacer />
<div
v-if="
!streams.running &&
Expand Down