-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add dataset_ids filter #286
Conversation
config/config.go
Outdated
@@ -13,6 +13,7 @@ type Config struct { | |||
BerlinAPIURL string `envconfig:"BERLIN_URL"` | |||
CategoryAPIURL string `envconfig:"CATEGORY_URL"` | |||
BindAddr string `envconfig:"BIND_ADDR"` | |||
DebugMode bool `envconfig:"DEBUG_MODE"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DebugMode bool `envconfig:"DEBUG_MODE"` | |
DebugMode bool `envconfig:"ENABLE_DEBUG"` |
for consistency with other boolean flags
though, I do wonder why/if this is needed at all (when would we use it in an environment? isn't this Dev-only?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linden, specified that he's rather we pick it up as a config.
api/search.go
Outdated
@@ -357,7 +484,7 @@ func LegacySearchHandlerFunc(validator QueryParamValidator, queryBuilder QueryBu | |||
|
|||
nlpCriteria := getNLPCriteria(ctx, params, nlpConfig, queryBuilder, clList) | |||
|
|||
q, searchReq, countReq := CreateRequests(w, req, validator, nlpCriteria) | |||
q, searchReq, countReq := CreateRequests(w, req, nlpConfig, validator, nlpCriteria) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q, searchReq, countReq := CreateRequests(w, req, nlpConfig, validator, nlpCriteria) | |
q, searchReq, countReq := CreateRequests(w, req, cfg, validator, nlpCriteria) |
should the param to this func be renamed to be consistent?
api/search.go
Outdated
return invalidDatasetIDs, err | ||
} | ||
|
||
func parseTopics(ctx context.Context, params url.Values) (topics []string, err string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func parseTopics(ctx context.Context, params url.Values) (topics []string, err string) { | |
func parseTopics(ctx context.Context, params url.Values) (topics []string, err error) { |
Is there a reason for using string
s where one would normally/consistently return error
?
These funcs seems to bounce between the two return types for a reaons that is unclear.
api/search.go
Outdated
return sanitisedQuery, nil | ||
} | ||
|
||
func parseLimit(ctx context.Context, params url.Values, validator QueryParamValidator) (limit int, err string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func parseLimit(ctx context.Context, params url.Values, validator QueryParamValidator) (limit int, err string) { | |
func parseLimit(ctx context.Context, params url.Values, validator QueryParamValidator) (limit int, err error) { |
see later
api/search.go
Outdated
|
||
if queryHasSpecialChars { | ||
log.Info(ctx, "rejecting query as it contains special characters", log.Data{"query": sanitisedQuery}) | ||
http.Error(w, "Invalid characters in query", http.StatusBadRequest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this func - a validator - should be calling http.Error
- perhaps move this back to the caller
api/search.go
Outdated
log.Info(ctx, "rejecting query as contained special characters", log.Data{"query": sanitisedQuery}) | ||
http.Error(w, "Invalid characters in query", http.StatusBadRequest) | ||
// Sanitize and validate the query string | ||
sanitisedQuery, err := sanitizeAndValidateQuery(ctx, w, params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sanitisedQuery, err := sanitizeAndValidateQuery(ctx, w, params) | |
sanitisedQuery, err := sanitiseAndValidateQuery(ctx, w, params) |
inconsistent spelling (z
in only 4 places)
api/search.go
Outdated
for _, topicID := range topics { | ||
if topicID == "" { | ||
invalidTopics = append(invalidTopics, "<blank>") | ||
} else if len(topicID) <= 1 || len(topicID) > 4 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps a comment here to explain this logic
swagger.yaml
Outdated
@@ -71,6 +71,14 @@ paths: | |||
type: string | |||
collectionFormat: csv | |||
required: false | |||
- in: query | |||
name: dataset_ids | |||
description: "Comma separated list of dataset IDs to filter the results." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: "Comma separated list of dataset IDs to filter the results." | |
description: "Comma-separated list of dataset IDs to filter the results." |
a8bcb00
to
2372309
Compare
What
add dataset_ids filter to search api
How to review
Check ok
Who can review
Anyone