Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
17 changes: 17 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ tasks:
cmds:
- go test {{ .CLI_ARGS }} ./...

go:test:meilisearch:
desc: Runs the Meilisearch search engine integration tests against a dockerized instance
dir: backend
cmds:
- docker run -d --rm --name homebox-meili-test -p 7711:7700 -e MEILI_MASTER_KEY=test-master-key -e MEILI_NO_ANALYTICS=true getmeili/meilisearch:v1.22
- defer: docker stop homebox-meili-test
- |
i=0
while [ "$i" -lt 60 ]; do
if curl -sf http://localhost:7711/health > /dev/null; then exit 0; fi
i=$((i + 1))
sleep 0.5
done
echo "Meilisearch did not become healthy within 30s" >&2
exit 1
- TEST_MEILISEARCH_URL=http://localhost:7711 TEST_MEILISEARCH_KEY=test-master-key go test ./internal/data/search/ -v -count=1

go:coverage:
desc: Runs all go tests with -race flag and generates a coverage report
dir: backend
Expand Down
2 changes: 1 addition & 1 deletion backend/app/api/cli_reset_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func generateResetLinkOffline(cfg *config.Config, email string) (string, error)
}

bus := eventbus.New()
repos := repo.New(c, bus, cfg.Storage, cfg.Database.PubSubConnString, cfg.Thumbnail)
repos := repo.New(c, bus, cfg.Storage, cfg.Database.PubSubConnString, cfg.Thumbnail, nil)
svc := services.New(repos)

baseURL := strings.TrimSuffix(cfg.Options.Hostname, "/")
Expand Down
14 changes: 8 additions & 6 deletions backend/app/api/handlers/v1/v1_ctrl_entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ func startEntityCtrlSpan(ctx context.Context, name string, attrs ...attribute.Ke
// @Summary Query All Entities
// @Tags Entities
// @Produce json
// @Param q query string false "search string"
// @Param page query int false "page number"
// @Param pageSize query int false "items per page"
// @Param tags query []string false "tags Ids" collectionFormat(multi)
// @Param parentIds query []string false "parent Ids" collectionFormat(multi)
// @Success 200 {object} repo.EntityListResult
// @Param q query string false "search string; matches names, descriptions, serial/model numbers, manufacturers, notes, purchase sources, tag names, and custom field values. Use #<assetId> to look up by asset ID and double quotes for exact phrases"
// @Param page query int false "page number"
// @Param pageSize query int false "items per page"
// @Param tags query []string false "tags Ids" collectionFormat(multi)
// @Param matchAllTags query bool false "require all selected tags to match (AND) instead of any (OR)"
// @Param parentIds query []string false "parent Ids" collectionFormat(multi)
// @Success 200 {object} repo.EntityListResult
// @Router /v1/entities [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleEntitiesGetAll() errchain.HandlerFunc {
Expand All @@ -80,6 +81,7 @@ func (ctrl *V1Controller) HandleEntitiesGetAll() errchain.HandlerFunc {
ParentIDs: queryUUIDList(params, "parentIds"),
TagIDs: queryUUIDList(params, "tags"),
NegateTags: queryBool(params.Get("negateTags")),
MatchAllTags: queryBool(params.Get("matchAllTags")),
OnlyWithoutPhoto: queryBool(params.Get("onlyWithoutPhoto")),
OnlyWithPhoto: queryBool(params.Get("onlyWithPhoto")),
IncludeArchived: queryBool(params.Get("includeArchived")),
Expand Down
9 changes: 8 additions & 1 deletion backend/app/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
"github.com/sysadminsmedia/homebox/backend/internal/data/search"
"github.com/sysadminsmedia/homebox/backend/internal/sys/analytics"
"github.com/sysadminsmedia/homebox/backend/internal/sys/config"
"github.com/sysadminsmedia/homebox/backend/internal/sys/otel"
Expand Down Expand Up @@ -162,7 +163,13 @@ func run(cfg *config.Config) error {

app.bus = eventbus.New()
app.db = c
app.repos = repo.New(c, app.bus, cfg.Storage, cfg.Database.PubSubConnString, cfg.Thumbnail)

searchEngine, err := search.NewEngine(cfg.Search, c, app.bus)
if err != nil {
log.Error().Err(err).Str("driver", cfg.Search.Driver).Msg("failed to create search engine")
return err
}
app.repos = repo.New(c, app.bus, cfg.Storage, cfg.Database.PubSubConnString, cfg.Thumbnail, searchEngine)

// Attachment-key escaping in fileblob only flattens paths on Windows
// (where os.PathSeparator is "\"), so the legacy-path rename is a Windows-
Expand Down
8 changes: 7 additions & 1 deletion backend/app/api/static/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const docTemplate = `{
"parameters": [
{
"type": "string",
"description": "search string",
"description": "search string; matches names, descriptions, serial/model numbers, manufacturers, notes, purchase sources, tag names, and custom field values. Use #\u003cassetId\u003e to look up by asset ID and double quotes for exact phrases",
"name": "q",
"in": "query"
},
Expand All @@ -273,6 +273,12 @@ const docTemplate = `{
"name": "tags",
"in": "query"
},
{
"type": "boolean",
"description": "require all selected tags to match (AND) instead of any (OR)",
"name": "matchAllTags",
"in": "query"
},
{
"type": "array",
"items": {
Expand Down
10 changes: 9 additions & 1 deletion backend/app/api/static/docs/openapi-3.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
"summary": "Query All Entities",
"parameters": [
{
"description": "search string",
"description": "search string; matches names, descriptions, serial/model numbers, manufacturers, notes, purchase sources, tag names, and custom field values. Use #<assetId> to look up by asset ID and double quotes for exact phrases",
"name": "q",
"in": "query",
"schema": {
Expand Down Expand Up @@ -280,6 +280,14 @@
}
}
},
{
"description": "require all selected tags to match (AND) instead of any (OR)",
"name": "matchAllTags",
"in": "query",
"schema": {
"type": "boolean"
}
},
{
"description": "parent Ids",
"name": "parentIds",
Expand Down
10 changes: 9 additions & 1 deletion backend/app/api/static/docs/openapi-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ paths:
- Entities
summary: Query All Entities
parameters:
- description: search string
- description: "search string; matches names, descriptions, serial/model numbers,
manufacturers, notes, purchase sources, tag names, and custom field
values. Use #<assetId> to look up by asset ID and double quotes for
exact phrases"
name: q
in: query
schema:
Expand All @@ -167,6 +170,11 @@ paths:
type: array
items:
type: string
- description: require all selected tags to match (AND) instead of any (OR)
name: matchAllTags
in: query
schema:
type: boolean
- description: parent Ids
name: parentIds
in: query
Expand Down
8 changes: 7 additions & 1 deletion backend/app/api/static/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
"parameters": [
{
"type": "string",
"description": "search string",
"description": "search string; matches names, descriptions, serial/model numbers, manufacturers, notes, purchase sources, tag names, and custom field values. Use #\u003cassetId\u003e to look up by asset ID and double quotes for exact phrases",
"name": "q",
"in": "query"
},
Expand All @@ -270,6 +270,12 @@
"name": "tags",
"in": "query"
},
{
"type": "boolean",
"description": "require all selected tags to match (AND) instead of any (OR)",
"name": "matchAllTags",
"in": "query"
},
{
"type": "array",
"items": {
Expand Down
8 changes: 7 additions & 1 deletion backend/app/api/static/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,9 @@ paths:
/v1/entities:
get:
parameters:
- description: search string
- description: 'search string; matches names, descriptions, serial/model numbers,
manufacturers, notes, purchase sources, tag names, and custom field values.
Use #<assetId> to look up by asset ID and double quotes for exact phrases'
in: query
name: q
type: string
Expand All @@ -2493,6 +2495,10 @@ paths:
type: string
name: tags
type: array
- description: require all selected tags to match (AND) instead of any (OR)
in: query
name: matchAllTags
type: boolean
- collectionFormat: multi
description: parent Ids
in: query
Expand Down
4 changes: 3 additions & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require (
github.com/gorilla/schema v1.4.1
github.com/hay-kot/httpkit v0.0.11
github.com/jackc/pgx/v5 v5.9.2
github.com/meilisearch/meilisearch-go v0.36.3
github.com/olahol/melody v1.4.0
github.com/pkg/errors v0.9.1
github.com/pressly/goose/v3 v3.27.1
Expand Down Expand Up @@ -95,6 +96,7 @@ require (
github.com/IBM/sarama v1.49.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/andybalholm/brotli v1.2.1 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.40.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 // indirect
Expand Down Expand Up @@ -150,7 +152,7 @@ require (
github.com/go-openapi/swag/yamlutils v0.26.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/wire v0.7.0 // indirect
Expand Down
Loading
Loading