Skip to content

Commit

Permalink
imp: make search params query case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
nesangcode committed Apr 8, 2024
1 parent 856b182 commit cc7428c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dist/
tmp/
.idea/

test.db
test.db-shm
Expand All @@ -10,3 +11,5 @@ test.db-wal

# Helm chart package
/developers-italia-api-*.tgz


2 changes: 1 addition & 1 deletion developers-italia.oas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ paths:
- schema:
type: string
maxLength: 255
example: 'SUCCESS'
example: 'debug'
in: query
name: search
description: Only logs message like this parameter
Expand Down
3 changes: 2 additions & 1 deletion internal/handlers/general/query.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package general

import (
"github.com/gofiber/fiber/v2/utils"
"time"

"github.com/gofiber/fiber/v2"
Expand Down Expand Up @@ -38,7 +39,7 @@ func Clauses(ctx *fiber.Ctx, stmt *gorm.DB, searchFieldName string) (*gorm.DB, e
}

if search := ctx.Query("search", ""); search != "" {
ret = stmt.Where("message LIKE ?", "%"+search+"%")
ret = stmt.Where("LOWER(message) LIKE ?", "%"+utils.ToLower(search)+"%")
}

return ret, nil
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3087,7 +3087,7 @@ func TestLogsEndpoints(t *testing.T) {
},
{
description: `GET with "search" query param`,
query: "GET /v1/logs?search=BulkOpsClient.",
query: "GET /v1/logs?search=debug",

expectedCode: 200,
expectedContentType: "application/json",
Expand Down

0 comments on commit cc7428c

Please sign in to comment.