Skip to content

The only tool you need to know what is happening and how to fix it.

feat: search added to endpoints

ddux365b575fb7a2
diff --git a/backend/app/controllers/endpoint.controller.go b/backend/app/controllers/endpoint.controller.go
index d8dbe0ed..bdf6de89 100644
--- a/backend/app/controllers/endpoint.controller.go
+++ b/backend/app/controllers/endpoint.controller.go
@@ -20,6 +20,7 @@ type EndpointSearchRequest struct {
OrderBy string `json:"orderBy"`
SortDirection string `json:"sortDirection"`
Pagination PaginationParams `json:"pagination"`
+ Search string `json:"search"`
}
type EndpointInstancesRequest struct {
@@ -89,7 +90,7 @@ func (e endpointController) FindGroupedByEndpoint(c *gin.Context) {
}
span := traceway.StartSpan(c, "loading grouped endpoints")
- stats, total, err := repositories.EndpointRepository.FindGroupedByEndpoint(c, projectId, request.FromDate, request.ToDate, request.Pagination.Page, request.Pagination.PageSize, request.OrderBy, request.SortDirection)
+ stats, total, err := repositories.EndpointRepository.FindGroupedByEndpoint(c, projectId, request.FromDate, request.ToDate, request.Pagination.Page, request.Pagination.PageSize, request.OrderBy, request.SortDirection, request.Search)
span.End()
if err != nil {
c.AbortWithError(500, traceway.NewStackTraceErrorf("error loading stats: %w", err))
diff --git a/backend/app/repositories/endpoint.repository.go b/backend/app/repositories/endpoint.repository.go
index ae6b28da..8f81f871 100644
--- a/backend/app/repositories/endpoint.repository.go
+++ b/backend/app/repositories/endpoint.repository.go
@@ -85,10 +85,20 @@ func (e *endpointRepository) FindAll(ctx context.Context, projectId uuid.UUID, f
return endpoints, int64(count), nil
}
-func (e *endpointRepository) FindGroupedByEndpoint(ctx context.Context, projectId uuid.UUID, fromDate, toDate time.Time, page, pageSize int, orderBy string, sortDirection string) ([]models.EndpointStats, int64, error) {
+func (e *endpointRepository) FindGroupedByEndpoint(ctx context.Context, projectId uuid.UUID, fromDate, toDate time.Time, page, pageSize int, orderBy string, sortDirection string, search string) ([]models.EndpointStats, int64, error) {
+ // Build WHERE clause with optional search filter
+ whereClause := "project_id = ? AND recorded_at >= ? AND recorded_at <= ?"
+ args := []interface{}{projectId, fromDate, toDate}
+
+ if search != "" {
+ whereClause += " AND positionCaseInsensitive(endpoint, ?) > 0"
+ args = append(args, search)
+ }
+
// Count unique endpoints
var count uint64
- err := (*chdb.Conn).QueryRow(ctx, "SELECT uniq(endpoint) FROM endpoints WHERE project_id = ? AND recorded_at >= ? AND recorded_at <= ?", projectId, fromDate, toDate).Scan(&count)
+ countQuery := "SELECT uniq(endpoint) FROM endpoints WHERE " + whereClause
+ err := (*chdb.Conn).QueryRow(ctx, countQuery, args...).Scan(&count)
if err != nil {
return nil, 0, err
}
@@ -146,12 +156,15 @@ func (e *endpointRepository) FindGroupedByEndpoint(ctx context.Context, projectI
)
) as impact
FROM endpoints
- WHERE project_id = ? AND recorded_at >= ? AND recorded_at <= ?
+ WHERE ` + whereClause + `
GROUP BY endpoint
ORDER BY ` + orderExpr + ` ` + sortDir + `
LIMIT ? OFFSET ?`
- rows, err := (*chdb.Conn).Query(ctx, query, projectId, fromDate, toDate, pageSize, offset)
+ // Add pagination args
+ queryArgs := append(args, pageSize, offset)
+
+ rows, err := (*chdb.Conn).Query(ctx, query, queryArgs...)
if err != nil {
return nil, 0, err
}
diff --git a/frontend/src/lib/components/ui/search-bar/index.ts b/frontend/src/lib/components/ui/search-bar/index.ts
new file mode 100644
index 00000000..ae38dee3
--- /dev/null
+++ b/frontend/src/lib/components/ui/search-bar/index.ts
@@ -0,0 +1,3 @@
+import SearchBar from './search-bar.svelte';
+
+export { SearchBar };
diff --git a/frontend/src/lib/components/ui/search-bar/search-bar.svelte b/frontend/src/lib/components/ui/search-bar/search-bar.svelte
new file mode 100644
index 00000000..2a88dec5
--- /dev/null
+++ b/frontend/src/lib/components/ui/search-bar/search-bar.svelte
@@ -0,0 +1,60 @@
+<script lang="ts">
+ import { Input } from '$lib/components/ui/input';
+ import { Button } from '$lib/components/ui/button';
+ import * as Select from '$lib/components/ui/select';
+
+ type TypeOption = {
+ value: string;
+ label: string;
+ };
+
+ type Props = {
+ placeholder?: string;
+ value?: string;
+ typeValue?: string;
+ typeOptions?: TypeOption[];
+ onSearch: () => void;
+ disabled?: boolean;
+ };
+
+ let {
+ placeholder = 'Search...',
+ value = $bindable(''),
+ typeValue = $bindable(''),
+ typeOptions = [],
+ onSearch,
+ disabled = false
+ }: Props = $props();
+
+ const typeLabel = $derived(typeOptions.find((o) => o.value === typeValue)?.label ?? '');
+</script>
+
+<div class="-mt-2 flex">
+ <Input
+ {placeholder}
+ class="h-9 w-[250px] rounded-r-none border-r-0 shadow-none focus-visible:border-r focus-visible:border-sidebar-accent focus-visible:ring-0 lg:w-[320px]"
+ bind:value
+ onkeydown={(e) => {
+ if (e.key === 'Enter') onSearch();
+ }}
+ />
+
+ {#if typeOptions.length > 0}
+ <Select.Root type="single" bind:value={typeValue}>
+ <Select.Trigger class="h-9 w-[110px] rounded-none border-r-0 shadow-none">
+ {typeLabel}
+ </Select.Trigger>
+ <Select.Content>
+ {#each typeOptions as option}
+ <Select.Item value={option.value} label={option.label}>
+ {option.label}
+ </Select.Item>
+ {/each}
+ </Select.Content>
+ </Select.Root>
+ {/if}
+
+ <Button variant="outline" class="h-9 rounded-l-none shadow-none" onclick={onSearch} {disabled}>
+ Go
+ </Button>
+</div>
diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte
index 0431bbbd..6126c6c2 100644
--- a/frontend/src/routes/+page.svelte
+++ b/frontend/src/routes/+page.svelte
@@ -91,9 +91,7 @@
);
const installCommand = $derived(
- projectWithToken
- ? getInstallCommand(projectWithToken.framework)
- : 'go get go.tracewayapp.com'
+ projectWithToken ? getInstallCommand(projectWithToken.framework) : 'go get go.tracewayapp.com'
);
const testingRouteCode = getTestingRouteCode();
@@ -141,10 +139,6 @@
}
}
- api.get('/account', {
- projectId: projectsState.currentProjectId ?? undefined
- });
-
async function loadDashboard(showFullPageLoading = true) {
if (showFullPageLoading) {
loading = true;
diff --git a/frontend/src/routes/endpoints/+page.svelte b/frontend/src/routes/endpoints/+page.svelte
index def08898..cd77683b 100644
--- a/frontend/src/routes/endpoints/+page.svelte
+++ b/frontend/src/routes/endpoints/+page.svelte
@@ -14,6 +14,8 @@
import { TableEmptyState } from "$lib/components/ui/table-empty-state";
import { PaginationFooter } from "$lib/components/ui/pagination-footer";
import { TimeRangePicker } from "$lib/components/ui/time-range-picker";
+ import { SearchBar } from "$lib/components/ui/search-bar";
+ import { browser } from '$app/environment';
import { CalendarDate } from "@internationalized/date";
import { projectsState } from '$lib/state/projects.svelte';
import { createRowClickHandler } from '$lib/utils/navigation';
@@ -88,10 +90,24 @@
let total = $state(0);
let totalPages = $state(0);
+ // Parse URL params including search
+ function parseEndpointsUrlParams() {
+ if (!browser) return { preset: '24h', from: null, to: null, search: '' };
+ const params = new URLSearchParams(window.location.search);
+ const timeParams = parseTimeRangeFromUrl(timezone, '24h');
+ return {
+ ...timeParams,
+ search: params.get('search') || ''
+ };
+ }
+
// Initialize from URL
- const initialUrlParams = parseTimeRangeFromUrl(timezone);
+ const initialUrlParams = parseEndpointsUrlParams();
const initialRange = getResolvedTimeRange(initialUrlParams, timezone);
+ // Search state
+ let searchQuery = $state(initialUrlParams.search);
+
// Date Range State
let selectedPreset = $state<string | null>(initialUrlParams.preset);
let fromDate = $state<CalendarDate>(dateToCalendarDate(initialRange.from, timezone));
@@ -99,19 +115,24 @@
let fromTime = $state(dateToTimeString(initialRange.from, timezone));
let toTime = $state(dateToTimeString(initialRange.to, timezone));
- // Update URL with current time range
+ // Update URL with current time range and search
function updateTimeRangeUrl(pushToHistory = true) {
- updateUrl(
- selectedPreset
- ? { preset: selectedPreset }
- : { from: getFromDateTimeUTC(), to: getToDateTimeUTC() },
- { pushToHistory }
- );
+ const params: Record<string, string | null | undefined> = {};
+ if (selectedPreset) {
+ params.preset = selectedPreset;
+ } else {
+ params.from = getFromDateTimeUTC();
+ params.to = getToDateTimeUTC();
+ }
+ if (searchQuery.trim()) {
+ params.search = searchQuery.trim();
+ }
+ updateUrl(params, { pushToHistory });
}
// Handle browser back/forward navigation
function handlePopState() {
- const urlParams = parseTimeRangeFromUrl(timezone);
+ const urlParams = parseEndpointsUrlParams();
const range = getResolvedTimeRange(urlParams, timezone);
selectedPreset = urlParams.preset;
@@ -119,6 +140,7 @@
fromTime = dateToTimeString(range.from, timezone);
toDate = dateToCalendarDate(range.to, timezone);
toTime = dateToTimeString(range.to, timezone);
+ searchQuery = urlParams.search;
page = 1;
loadData(false);
@@ -230,7 +252,8 @@
pagination: {
page: page,
pageSize: pageSize
- }
+ },
+ search: searchQuery.trim()
};
const response = await api.post('/endpoints/grouped', requestBody, { projectId: projectsState.currentProjectId ?? undefined });
@@ -276,6 +299,11 @@
loadChartData();
}
+ function handleSearch() {
+ page = 1;
+ loadData(true);
+ }
+
function handleChartRangeSelect(from: Date, to: Date) {
selectedPreset = null;
fromDate = new CalendarDate(from.getFullYear(), from.getMonth() + 1, from.getDate());
@@ -357,6 +385,14 @@
</div>
</div>
+ <!-- Search -->
+ <SearchBar
+ placeholder="Search endpoints..."
+ bind:value={searchQuery}
+ onSearch={handleSearch}
+ disabled={loading}
+ />
+
<!-- Performance Chart -->
<Card.Root class="pt-2">
<Card.Header class="flex flex-row items-center justify-between space-y-0 border-b [.border-b]:pb-2 pl-3">
diff --git a/frontend/src/routes/issues/+page.svelte b/frontend/src/routes/issues/+page.svelte
index 9f8b58f9..bc0601d7 100644
--- a/frontend/src/routes/issues/+page.svelte
+++ b/frontend/src/routes/issues/+page.svelte
@@ -4,9 +4,7 @@
import { createRowClickHandler } from '$lib/utils/navigation';
import { api } from '$lib/api';
import * as Table from '$lib/components/ui/table';
- import { Input } from '$lib/components/ui/input';
- import { Button } from '$lib/components/ui/button';
- import * as Select from '$lib/components/ui/select';
+ import { SearchBar } from '$lib/components/ui/search-bar';
import { LoadingCircle } from '$lib/components/ui/loading-circle';
import { Checkbox } from '$lib/components/ui/checkbox';
import { projectsState } from '$lib/state/projects.svelte';
@@ -110,9 +108,6 @@
{ value: 'messages', label: 'Messages' }
];
- const searchTypeLabel = $derived(
- searchTypeOptions.find((o) => o.value === searchType)?.label ?? 'All'
- );
// Page size options
const pageSizeOptions = [
@@ -327,35 +322,15 @@
</div>
</div>
- <!-- Row 2: Search Type Dropdown + Search Input + Go Button -->
- <div class="flex">
-
- <Input
- placeholder="Search exceptions..."
- class="h-9 w-[250px] rounded-r-none border-r-0 lg:w-[320px]"
- bind:value={searchQuery}
- onkeydown={(e) => {
- if (e.key === 'Enter') handleSearch();
- }}
- />
-
- <Select.Root type="single" bind:value={searchType}>
- <Select.Trigger class="h-9 w-[110px] rounded-none border-r-0">
- {searchTypeLabel}
- </Select.Trigger>
- <Select.Content>
- {#each searchTypeOptions as option}
- <Select.Item value={option.value} label={option.label}>
- {option.label}
- </Select.Item>
- {/each}
- </Select.Content>
- </Select.Root>
-
- <Button variant="outline" class="h-9 rounded-l-none" onclick={handleSearch} disabled={loading}>
- Go
- </Button>
- </div>
+ <!-- Row 2: Search -->
+ <SearchBar
+ placeholder="Search exceptions..."
+ bind:value={searchQuery}
+ bind:typeValue={searchType}
+ typeOptions={searchTypeOptions}
+ onSearch={handleSearch}
+ disabled={loading}
+ />
<!-- Archive Toolbar - shown when items selected -->
{#if selectedCount > 0}