From 1a46c4a199f8d88fa06dbd2bc00fb9c8460c9b54 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 21 Dec 2023 23:10:41 +0700 Subject: [PATCH 1/8] feat(events): add event search --- .../openapi/components/schemas/_index.yaml | 2 + .../openapi/components/schemas/event.yaml | 3 + api-contracts/openapi/paths/event/event.yaml | 6 + api/v1/server/handlers/events/list.go | 4 + api/v1/server/oas/gen/openapi.gen.go | 107 ++++++++++-------- .../data-table/data-table-toolbar.tsx | 17 +-- .../molecules/data-table/data-table.tsx | 14 ++- frontend/app/src/lib/api/generated/Api.ts | 3 + .../src/lib/api/generated/data-contracts.ts | 2 + frontend/app/src/pages/main/events/index.tsx | 9 +- internal/repository/event.go | 3 + internal/repository/prisma/dbsqlc/events.sql | 12 +- .../repository/prisma/dbsqlc/events.sql.go | 18 ++- internal/repository/prisma/event.go | 5 + 14 files changed, 135 insertions(+), 70 deletions(-) diff --git a/api-contracts/openapi/components/schemas/_index.yaml b/api-contracts/openapi/components/schemas/_index.yaml index 10e699990..f5a496890 100644 --- a/api-contracts/openapi/components/schemas/_index.yaml +++ b/api-contracts/openapi/components/schemas/_index.yaml @@ -36,6 +36,8 @@ EventOrderByField: $ref: "./event.yaml#/EventOrderByField" EventOrderByDirection: $ref: "./event.yaml#/EventOrderByDirection" +EventSearch: + $ref: "./event.yaml#/EventSearch" EventKeyList: $ref: "./event.yaml#/EventKeyList" EventKey: diff --git a/api-contracts/openapi/components/schemas/event.yaml b/api-contracts/openapi/components/schemas/event.yaml index 50552ffc6..08aa66784 100644 --- a/api-contracts/openapi/components/schemas/event.yaml +++ b/api-contracts/openapi/components/schemas/event.yaml @@ -91,3 +91,6 @@ EventOrderByDirection: enum: - asc - desc + +EventSearch: + type: string diff --git a/api-contracts/openapi/paths/event/event.yaml b/api-contracts/openapi/paths/event/event.yaml index 971cfc82a..8068d02b9 100644 --- a/api-contracts/openapi/paths/event/event.yaml +++ b/api-contracts/openapi/paths/event/event.yaml @@ -35,6 +35,12 @@ withTenant: type: array items: $ref: "../../components/schemas/_index.yaml#/EventKey" + - description: The search query to filter for + in: query + name: search + required: false + schema: + $ref: "../../components/schemas/_index.yaml#/EventSearch" - description: What to order by in: query name: orderByField diff --git a/api/v1/server/handlers/events/list.go b/api/v1/server/handlers/events/list.go index f2b2cf1a8..154451e04 100644 --- a/api/v1/server/handlers/events/list.go +++ b/api/v1/server/handlers/events/list.go @@ -22,6 +22,10 @@ func (t *EventService) EventList(ctx echo.Context, request gen.EventListRequestO Offset: &offset, } + if request.Params.Search != nil { + listOpts.Search = request.Params.Search + } + if request.Params.Keys != nil { listOpts.Keys = *request.Params.Keys } diff --git a/api/v1/server/oas/gen/openapi.gen.go b/api/v1/server/oas/gen/openapi.gen.go index f5aa2c912..492424a7a 100644 --- a/api/v1/server/oas/gen/openapi.gen.go +++ b/api/v1/server/oas/gen/openapi.gen.go @@ -153,6 +153,9 @@ type EventOrderByDirection string // EventOrderByField defines model for EventOrderByField. type EventOrderByField string +// EventSearch defines model for EventSearch. +type EventSearch = string + // EventWorkflowRunSummary defines model for EventWorkflowRunSummary. type EventWorkflowRunSummary struct { // Failed The number of failed runs. @@ -488,6 +491,9 @@ type EventListParams struct { // Keys A list of keys to filter by Keys *[]EventKey `form:"keys,omitempty" json:"keys,omitempty"` + // Search The search query to filter for + Search *EventSearch `form:"search,omitempty" json:"search,omitempty"` + // OrderByField What to order by OrderByField *EventOrderByField `form:"orderByField,omitempty" json:"orderByField,omitempty"` @@ -668,6 +674,13 @@ func (w *ServerInterfaceWrapper) EventList(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter keys: %s", err)) } + // ------------- Optional query parameter "search" ------------- + + err = runtime.BindQueryParameter("form", true, false, "search", ctx.QueryParams(), ¶ms.Search) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter search: %s", err)) + } + // ------------- Optional query parameter "orderByField" ------------- err = runtime.BindQueryParameter("form", true, false, "orderByField", ctx.QueryParams(), ¶ms.OrderByField) @@ -2263,53 +2276,53 @@ var swaggerSpec = []string{ "HDMQOMJajZdYjpLWSwOiGLOsoxZ80f4s8pN7dlJm+FMra2xw5UIeKLsbx/RhmCVX2WyG2XwZZYqhnxa7", "PRVMzqKOYrazkFsrlhPsM4SWr4uLlW/KwkH/99vV75doNBfA/7+33GXIofPp/7keBuwY58SnmimekATb", "OKGOoR/zlkPgKU04yNEZfWjuoPLlLDooS+i2UFlD4u8sAvZufkIYhJYkSLKZlBzmYaCjL0fLn8jC9P/F", - "xia2b2F0K7t+8qpBmVdjTGKoUMMkm42ASVXUrRDLEt5zHUV1SJlCEklalgxsmrUZmWVJ0mBk06zNyDwL", - "Q4BoOTvyhs1Hl3j4jY48hqEu9lb2wYm+jVX8SkebNuDW6S6MyQWkzbXhSkC6qAxle78whYw0aCb8yzcv", - "ly39HhgnNPHOUG3Dc7LcATq5+1VL9/nf3+homCWecBcnIcSxDdmaxaR5p3wTWN1kCJhroHh2Lwnh03ZT", - "f9WIrJOoBK1uWSG9NUDHgGexcEYtOMwFZqLdYrjAIuMN1iPtoW5r8D3MknYQl8Jvj/LwDli9CrRZrhPk", - "LCPZcQRPeq6uL+VBLEByKVRrzVUuJuvKPp5enpxdfgg6wfDm8lI/Xd28f396enJ6EnSCX47PztXD++PL", - "96fn8tnn8zzOXE5idz4/gjBjDBLxJcUTCAYHnSCB7/a/w06QZDP1Dw8G+3vShZVVu9TZtx0zLVCqEx75", - "xAeNnI9Di29w+Xph5MNmIxfr8u4iqcCx65JlUxUpxoQLvbspckp7TXydR/ZDSGM8V2FJ5cZPRaVnUVkV", - "X3rPXZ8KsRTKcFv5uoVF4DzK81nbzdtQCYyKURngCI9iqNpm2fd59gOQtIZe/7oxB14xQ7XNcVZRMkDW", - "4BiG55zwWR5rs7fKYUNl71VcOUnSTFTBroGPMCFN3v5FkUozUUV9yuC+Et/fMsjgeCyANWfUnxF0GPyV", - "o46msbRsW6V4DbSybU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XKQDPRTBvkUFuCUUnKDqSv", + "x45r9DSF7ay4dd+gUmw2VE6n/HvBtZGK/4b/MwPcP2mLUu3iandBcXMYEi58HFwOSWa+4VFXr9UteK0x", + "fdYTmb6PjWxDYGGZt4vCX0WIYSG03Fyb6pOuEwFrUiHyGGJdsWpYCTLfzKgrt+jPW73a8ugKCZIt06et", + "qYu2KIvajwQuAlxnjvNSaOMyaKPEcQvUmzxhfZnxlVdSVkwO7tDvzwuuWFdcrgN995MjTZTBXshrpBTm", + "euEr0o365L5ZfA+djZUT5pmEBEQdBeIYC+Ai5xDhaAwinEJUVQEobhG+JtXOP32xWvr/vvhyxt9Y0+Ws", + "Ry8z6yUVaEyzJKqrOxRQfGY7049KN6DbmBznSnRL6+Pcht7Zob+YHXJku55FcvC1M07baJxcAa1up56m", + "mdxb+J9vpeJ5Ek/A7q29yFgcDILg8fbxvwEAAP//f0A071J1AAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx b/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx index 1d8d7bc12..d061906c9 100644 --- a/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx +++ b/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx @@ -5,6 +5,7 @@ import { Button } from '@/components/ui/button'; import { DataTableViewOptions } from './data-table-view-options'; import { DataTableFacetedFilter } from './data-table-faceted-filter'; +import { Input } from '@/components/ui/input.tsx'; export interface FilterOption { label: string; @@ -22,26 +23,28 @@ interface DataTableToolbarProps { table: Table; filters: ToolbarFilters; actions: JSX.Element[]; + setSearch?: (search: string) => void; + search?: string; } export function DataTableToolbar({ table, filters, actions, + setSearch, + search, }: DataTableToolbarProps) { const isFiltered = table.getState().columnFilters.length > 0; return (
- {/* - table.getColumn("title")?.setFilterValue(event.target.value) - } + setSearch && setSearch(e.target.value)} className="h-8 w-[150px] lg:w-[250px]" - /> */} + /> {filters.map( (filter) => table.getColumn(filter.columnId) && ( diff --git a/frontend/app/src/components/molecules/data-table/data-table.tsx b/frontend/app/src/components/molecules/data-table/data-table.tsx index 8bf5c109e..d803876a8 100644 --- a/frontend/app/src/components/molecules/data-table/data-table.tsx +++ b/frontend/app/src/components/molecules/data-table/data-table.tsx @@ -48,6 +48,8 @@ interface DataTableProps { actions?: JSX.Element[]; sorting?: SortingState; setSorting?: OnChangeFn; + setSearch?: (search: string) => void; + search?: string; columnFilters?: ColumnFiltersState; setColumnFilters?: OnChangeFn; pagination?: PaginationState; @@ -76,6 +78,8 @@ export function DataTable({ actions = [], sorting, setSorting, + setSearch, + search, columnFilters, setColumnFilters, pagination, @@ -90,7 +94,7 @@ export function DataTable({ getRowId, }: DataTableProps) { const tableData = React.useMemo( - () => (isLoading ? Array(10).fill({}) : data), + () => (isLoading ? Array(10).fill({ metadata: {} }) : data), [isLoading, data], ); @@ -160,7 +164,13 @@ export function DataTable({ return (
{filters && filters.length > 0 && ( - + )}
diff --git a/frontend/app/src/lib/api/generated/Api.ts b/frontend/app/src/lib/api/generated/Api.ts index 2e4731648..ed2398e39 100644 --- a/frontend/app/src/lib/api/generated/Api.ts +++ b/frontend/app/src/lib/api/generated/Api.ts @@ -19,6 +19,7 @@ import { EventList, EventOrderByDirection, EventOrderByField, + EventSearch, ReplayEventRequest, Tenant, User, @@ -165,6 +166,8 @@ export class Api extends HttpClient(undefined); const [sorting, setSorting] = useState([]); const [columnFilters, setColumnFilters] = useState([]); const [pagination, setPagination] = useState({ @@ -134,6 +135,7 @@ function EventsTable() { orderByDirection, offset, limit: pageSize, + search, }), }); @@ -170,10 +172,6 @@ function EventsTable() { // } // }, [listEventsQuery.data?.pagination]); - if (listEventsQuery.isLoading) { - return ; - } - const tableColumns = columns({ onRowClick: (row: Event) => { setSelectedEvent(row); @@ -225,6 +223,7 @@ function EventsTable() { {selectedEvent && } >'title' like '%Board%' ) GROUP BY events."id" ORDER BY - case when $3 = 'createdAt ASC' THEN events."createdAt" END ASC , - case when $3 = 'createdAt DESC' then events."createdAt" END DESC + case when $4 = 'createdAt ASC' THEN events."createdAt" END ASC , + case when $4 = 'createdAt DESC' then events."createdAt" END DESC OFFSET - COALESCE($4, 0) + COALESCE($5, 0) LIMIT - COALESCE($5, 50) + COALESCE($6, 50) ` type ListEventsParams struct { TenantId pgtype.UUID `json:"tenantId"` Keys []string `json:"keys"` + Search interface{} `json:"search"` Orderby interface{} `json:"orderby"` Offset interface{} `json:"offset"` Limit interface{} `json:"limit"` @@ -125,6 +130,7 @@ func (q *Queries) ListEvents(ctx context.Context, db DBTX, arg ListEventsParams) rows, err := db.Query(ctx, listEvents, arg.TenantId, arg.Keys, + arg.Search, arg.Orderby, arg.Offset, arg.Limit, diff --git a/internal/repository/prisma/event.go b/internal/repository/prisma/event.go index a81b784fa..891abd583 100644 --- a/internal/repository/prisma/event.go +++ b/internal/repository/prisma/event.go @@ -50,6 +50,11 @@ func (r *eventRepository) ListEvents(tenantId string, opts *repository.ListEvent TenantId: *pgTenantId, } + if opts.Search != nil { + queryParams.Search.String = *opts.Search + queryParams.Search.Valid = true + } + if opts.Offset != nil { queryParams.Offset = *opts.Offset } From 87f38b0f5cb6d05e5de0e80eef5db82bc3dfeae2 Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Fri, 22 Dec 2023 13:26:02 +0700 Subject: [PATCH 2/8] Update internal/repository/prisma/event.go Co-authored-by: abelanger5 --- internal/repository/prisma/event.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/repository/prisma/event.go b/internal/repository/prisma/event.go index 891abd583..889dcdc75 100644 --- a/internal/repository/prisma/event.go +++ b/internal/repository/prisma/event.go @@ -51,7 +51,7 @@ func (r *eventRepository) ListEvents(tenantId string, opts *repository.ListEvent } if opts.Search != nil { - queryParams.Search.String = *opts.Search + queryParams.Search = sqlchelpers.TextFromStr(opts.Search) queryParams.Search.Valid = true } From 5c80b10398f4518309c62bf568e4efe73a9de6e6 Mon Sep 17 00:00:00 2001 From: steebchen Date: Fri, 22 Dec 2023 15:39:51 +0700 Subject: [PATCH 3/8] fix event.go --- internal/repository/prisma/event.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/repository/prisma/event.go b/internal/repository/prisma/event.go index 889dcdc75..ac0ca8e22 100644 --- a/internal/repository/prisma/event.go +++ b/internal/repository/prisma/event.go @@ -6,6 +6,7 @@ import ( "github.com/hatchet-dev/hatchet/internal/repository" "github.com/hatchet-dev/hatchet/internal/repository/prisma/db" "github.com/hatchet-dev/hatchet/internal/repository/prisma/dbsqlc" + "github.com/hatchet-dev/hatchet/internal/repository/prisma/sqlchelpers" "github.com/hatchet-dev/hatchet/internal/validator" "github.com/jackc/pgx/v5/pgtype" "github.com/jackc/pgx/v5/pgxpool" @@ -51,8 +52,7 @@ func (r *eventRepository) ListEvents(tenantId string, opts *repository.ListEvent } if opts.Search != nil { - queryParams.Search = sqlchelpers.TextFromStr(opts.Search) - queryParams.Search.Valid = true + queryParams.Search = sqlchelpers.TextFromStr(*opts.Search) } if opts.Offset != nil { From b07a1f818577f30f8ee8e50096fdb3625c1e44fb Mon Sep 17 00:00:00 2001 From: steebchen Date: Fri, 22 Dec 2023 15:51:21 +0700 Subject: [PATCH 4/8] fix seed.go --- cmd/hatchet-admin/cli/seed.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/hatchet-admin/cli/seed.go b/cmd/hatchet-admin/cli/seed.go index f986a38bd..913203d7a 100644 --- a/cmd/hatchet-admin/cli/seed.go +++ b/cmd/hatchet-admin/cli/seed.go @@ -130,12 +130,12 @@ func seedDev(repo repository.Repository, tenantId string) error { "message": "Above message is: {{ .steps.echo1.message }}", }) - workflow, err := repo.Workflow().GetWorkflowByName(tenantId, "test-workflow") + _, err := repo.Workflow().GetWorkflowByName(tenantId, "test-workflow") if err != nil { if errors.Is(err, db.ErrNotFound) { - _, err := repo.Workflow().CreateNewWorkflow(tenantId, &repository.CreateWorkflowVersionOpts{ + workflow, err := repo.Workflow().CreateNewWorkflow(tenantId, &repository.CreateWorkflowVersionOpts{ Name: "test-workflow", Description: repository.StringPtr("This is a test workflow."), Version: "v0.1.0", @@ -175,7 +175,7 @@ func seedDev(repo repository.Repository, tenantId string) error { return err } - fmt.Println("created workflow", workflow.ID, workflow.Name) + fmt.Println("created workflow", workflow.ID, workflow.Workflow().Name) } return err From be163d79fe1589c08bebf759133eb0ea5bab5683 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 28 Dec 2023 21:26:34 +0700 Subject: [PATCH 5/8] use simple sql query for now --- internal/repository/prisma/dbsqlc/events.sql | 6 +++--- internal/repository/prisma/dbsqlc/events.sql.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/repository/prisma/dbsqlc/events.sql b/internal/repository/prisma/dbsqlc/events.sql index a429ba129..47b872896 100644 --- a/internal/repository/prisma/dbsqlc/events.sql +++ b/internal/repository/prisma/dbsqlc/events.sql @@ -30,9 +30,9 @@ WHERE events."key" = ANY(sqlc.narg('keys')::text[]) ) AND ( - sqlc.narg('search') IS NULL OR - events."data" = sqlc.narg('search') -- TODO!! - ) + sqlc.narg('search')::text IS NULL OR + events."data"::text like concat('%', sqlc.narg('search')::text, '%') + ) GROUP BY events."id" ORDER BY diff --git a/internal/repository/prisma/dbsqlc/events.sql.go b/internal/repository/prisma/dbsqlc/events.sql.go index 166e34c43..8fcde7a28 100644 --- a/internal/repository/prisma/dbsqlc/events.sql.go +++ b/internal/repository/prisma/dbsqlc/events.sql.go @@ -95,8 +95,8 @@ WHERE events."key" = ANY($2::text[]) ) AND ( - $3 IS NULL OR - events."search" = data->>'title' like '%Board%' + $3::text IS NULL OR + events."data"::text like concat('%', $3::text, '%') ) GROUP BY events."id" @@ -112,7 +112,7 @@ LIMIT type ListEventsParams struct { TenantId pgtype.UUID `json:"tenantId"` Keys []string `json:"keys"` - Search interface{} `json:"search"` + Search pgtype.Text `json:"search"` Orderby interface{} `json:"orderby"` Offset interface{} `json:"offset"` Limit interface{} `json:"limit"` From b69fb74bb92d4218908ebabf9f1a5d213aca7420 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 28 Dec 2023 21:34:45 +0700 Subject: [PATCH 6/8] use jsonb_path_exists --- internal/repository/prisma/dbsqlc/events.sql | 2 +- internal/repository/prisma/dbsqlc/events.sql.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/repository/prisma/dbsqlc/events.sql b/internal/repository/prisma/dbsqlc/events.sql index 47b872896..636bccd48 100644 --- a/internal/repository/prisma/dbsqlc/events.sql +++ b/internal/repository/prisma/dbsqlc/events.sql @@ -31,7 +31,7 @@ WHERE ) AND ( sqlc.narg('search')::text IS NULL OR - events."data"::text like concat('%', sqlc.narg('search')::text, '%') + jsonb_path_exists(events."data", cast(concat('$.** ? (@.type() == "string" && @ like_regex "', sqlc.narg('search')::text, '")') as jsonpath)) ) GROUP BY events."id" diff --git a/internal/repository/prisma/dbsqlc/events.sql.go b/internal/repository/prisma/dbsqlc/events.sql.go index 8fcde7a28..a0a14573a 100644 --- a/internal/repository/prisma/dbsqlc/events.sql.go +++ b/internal/repository/prisma/dbsqlc/events.sql.go @@ -96,7 +96,7 @@ WHERE ) AND ( $3::text IS NULL OR - events."data"::text like concat('%', $3::text, '%') + jsonb_path_exists(events."data", cast(concat('$.** ? (@.type() == "string" && @ like_regex "', $3::text, '")') as jsonpath)) ) GROUP BY events."id" @@ -126,6 +126,7 @@ type ListEventsRow struct { Failedruns int64 `json:"failedruns"` } +// jsonb_path_exists(events."data", '$.** ? (@.type() == "string" && @ like_regex "asdf")') func (q *Queries) ListEvents(ctx context.Context, db DBTX, arg ListEventsParams) ([]*ListEventsRow, error) { rows, err := db.Query(ctx, listEvents, arg.TenantId, From 6ad3afd1ecd85709f131b349ad3dfd71762caea5 Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Thu, 28 Dec 2023 22:58:36 +0700 Subject: [PATCH 7/8] Update frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx Co-authored-by: abelanger5 --- .../src/components/molecules/data-table/data-table-toolbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx b/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx index d061906c9..026770196 100644 --- a/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx +++ b/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx @@ -40,7 +40,7 @@ export function DataTableToolbar({
setSearch && setSearch(e.target.value)} className="h-8 w-[150px] lg:w-[250px]" From 849ce117156ca2bef6c4f0dae6c3231012b328c9 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 28 Dec 2023 23:41:26 +0700 Subject: [PATCH 8/8] only render search bar when setSearch is provided --- .../molecules/data-table/data-table-toolbar.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx b/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx index 026770196..4e20a1395 100644 --- a/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx +++ b/frontend/app/src/components/molecules/data-table/data-table-toolbar.tsx @@ -39,12 +39,14 @@ export function DataTableToolbar({ return (
- setSearch && setSearch(e.target.value)} - className="h-8 w-[150px] lg:w-[250px]" - /> + {setSearch && ( + setSearch(e.target.value)} + className="h-8 w-[150px] lg:w-[250px]" + /> + )} {filters.map( (filter) => table.getColumn(filter.columnId) && (