diff --git a/api/filters.go b/api/filters.go index 4380ad2c..48e73ed0 100644 --- a/api/filters.go +++ b/api/filters.go @@ -479,6 +479,10 @@ func (api *FilterAPI) getDimensionOptionsBatchProcess(ctx context.Context, dimen return nil } + // get encoded IDs so that they can be used as query paramters + encodedIDs := dimension.EncodedOptions() + + // validate the options with Dataset API, in batches err := api.datasetAPI.GetOptionsBatchProcess(ctx, getUserAuthToken(ctx), api.serviceAuthToken, @@ -487,7 +491,7 @@ func (api *FilterAPI) getDimensionOptionsBatchProcess(ctx context.Context, dimen dataset.Edition, strconv.Itoa(dataset.Version), dimension.Name, - &dimension.Options, + &encodedIDs, processBatch, api.maxDatasetOptions, api.BatchMaxWorkers) diff --git a/go.mod b/go.mod index 864aac10..2f08af7d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ONSdigital/dp-filter-api go 1.15 require ( - github.com/ONSdigital/dp-api-clients-go v1.32.6 + github.com/ONSdigital/dp-api-clients-go v1.32.10 github.com/ONSdigital/dp-graph/v2 v2.3.0 github.com/ONSdigital/dp-healthcheck v1.0.5 github.com/ONSdigital/dp-kafka/v2 v2.1.2 diff --git a/go.sum b/go.sum index 3ae24149..c6f64616 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/ONSdigital/dp-api-clients-go v1.1.0/go.mod h1:9lqor0I7caCnRWr04gU/r7x5dqxgoODob8L48q+cE4E= github.com/ONSdigital/dp-api-clients-go v1.28.0/go.mod h1:iyJy6uRL4B6OYOJA0XMr5UHt6+Q8XmN9uwmURO+9Oj4= -github.com/ONSdigital/dp-api-clients-go v1.32.6 h1:jLAhlSAFx8iV9P9K5TBEkzQMnl3gxAT5IzvyKSE3tQ0= -github.com/ONSdigital/dp-api-clients-go v1.32.6/go.mod h1:0pUK3MN1v7DTjq0JSAD+DqbsZ8AVTodrXSXgJecg9Pw= +github.com/ONSdigital/dp-api-clients-go v1.32.10 h1:oH3+9PHPn4EFr/m4tEdLi/yW1W6vu5t+gNE8qPzr0lM= +github.com/ONSdigital/dp-api-clients-go v1.32.10/go.mod h1:0pUK3MN1v7DTjq0JSAD+DqbsZ8AVTodrXSXgJecg9Pw= github.com/ONSdigital/dp-frontend-models v1.1.0/go.mod h1:TT96P7Mi69N3Tc/jFNdbjiwG4GAaMjP26HLotFQ6BPw= github.com/ONSdigital/dp-graph/v2 v2.3.0 h1:xK9qImVbh86l04aAUeurjB7d8mwn27eacP+5gpvPLO8= github.com/ONSdigital/dp-graph/v2 v2.3.0/go.mod h1:K4LIhFcyxB8g7nUG5I5I8x6QVf89x82dCEFBbE0mmaQ= diff --git a/models/models.go b/models/models.go index a8e8e514..a767e4fa 100644 --- a/models/models.go +++ b/models/models.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "io/ioutil" + "net/url" "time" "github.com/ONSdigital/dp-api-clients-go/dataset" @@ -75,6 +76,15 @@ type Dimension struct { Options []string `bson:"options" json:"options"` } +// EncodedOptions returns the list of options for this dimension after escaping the values for URL query paramters +func (d *Dimension) EncodedOptions() []string { + encodedIDs := make([]string, len(d.Options)) + for i, op := range d.Options { + encodedIDs[i] = url.QueryEscape(op) + } + return encodedIDs +} + // PublicDimension represents information about a single dimension as served by /dimensions and /dimensions/ type PublicDimension struct { Name string `bson:"name" json:"name"`