Skip to content
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

Merged
merged 2 commits into from
Aug 29, 2024
Merged

Conversation

Oluwawunmi
Copy link
Contributor

What

add dataset_ids filter to search api

How to review

Check ok

Who can review

Anyone

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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?)

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 strings 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Contributor

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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "Comma separated list of dataset IDs to filter the results."
description: "Comma-separated list of dataset IDs to filter the results."

@Oluwawunmi Oluwawunmi force-pushed the feature/add-datasetid-filter-to-search branch from a8bcb00 to 2372309 Compare August 28, 2024 16:42
@Oluwawunmi Oluwawunmi merged commit 2372309 into develop Aug 29, 2024
5 checks passed
@Oluwawunmi Oluwawunmi deleted the feature/add-datasetid-filter-to-search branch August 29, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants