Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoubfaouzi committed Oct 11, 2024
1 parent 27b9095 commit a0d57d6
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 43 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ generate/doc: ## Generate OpenAPI spec.
&& sed -i "s|$$old|$$new|g" ${ROOT_DIR}/docs/docs.go

format/sql: ## Format N1QL files.
# npm install sql-formatter
@for file in ./db/*.sql; do \
npx sql-formatter $$file -l n1ql --fix; \
done
4 changes: 2 additions & 2 deletions internal/behavior/repostitory.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (r repository) CountEvents(ctx context.Context, id string) (int, error) {
}

if k == "q" {
statement += fmt.Sprintf(" LOWER(event.`path`) LIKE LOWER($q)")
statement += " LOWER(event.`path`) LIKE LOWER($q)"
params[k] = "%" + v[0] + "%"
} else {
statement += fmt.Sprintf(" event.%s IN $%s", k, k)
Expand Down Expand Up @@ -309,7 +309,7 @@ func (r repository) Events(ctx context.Context, id string, offset,
}

if k == "q" {
statement += fmt.Sprintf(" LOWER(event.`path`) LIKE LOWER($q)")
statement += " LOWER(event.`path`) LIKE LOWER($q)"
params[k] = "%" + v[0] + "%"
} else {
statement += fmt.Sprintf(" event.%s IN $%s", k, k)
Expand Down
21 changes: 0 additions & 21 deletions internal/file/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,6 @@ func areFieldsAllowed(fields []string) bool {
return true
}

// isStringInSlice check if a string exist in a list of strings
func isStringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}

return false
}

// removeStringFromSlice removes a string item from a list of strings.
func removeStringFromSlice(s []string, r string) []string {
for i, v := range s {
if v == r {
return append(s[:i], s[i+1:]...)
}
}
return s
}

// hash calculates the sha256 hash over a stream of bytes.
func hash(b []byte) string {
h := sha256.New()
Expand Down
20 changes: 0 additions & 20 deletions internal/user/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@ import (
"net/http"
)

// isStringInSlice check if a string exist in a list of strings
func isStringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}

return false
}

// removeStringFromSlice removes a string item from a list of strings.
func removeStringFromSlice(s []string, r string) []string {
for i, v := range s {
if v == r {
return append(s[:i], s[i+1:]...)
}
}
return s
}

// downloadURLContent reads a response from an URL content.
func downloadURLContent(url string) (*bytes.Buffer, error) {
Expand Down

0 comments on commit a0d57d6

Please sign in to comment.