Skip to content

Commit

Permalink
Merge branch 'release/2.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSubiros committed Jan 26, 2021
2 parents a89a59e + 635709c commit fb7c34d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion api/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
10 changes: 10 additions & 0 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net/url"
"time"

"github.com/ONSdigital/dp-api-clients-go/dataset"
Expand Down Expand Up @@ -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/<id>
type PublicDimension struct {
Name string `bson:"name" json:"name"`
Expand Down

0 comments on commit fb7c34d

Please sign in to comment.