Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
add filter.NewSPRFilterFromQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaroland committed Sep 27, 2017
1 parent 9311610 commit 28a1c72
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
23 changes: 23 additions & 0 deletions filter/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package filter

import (
"net/url"
)

func NewSPRFilterFromQuery(query url.Values) (Filter, error) {

inputs, err := NewSPRInputs()

if err != nil {
return nil, err
}

inputs.Placetypes = query["placetype"]
inputs.IsCurrent = query["is_current"]
inputs.IsDeprecated = query["is_deprecated"]
inputs.IsCeased = query["is_ceased"]
inputs.IsSuperseded = query["is_superseded"]
inputs.IsSuperseding = query["is_superseding"]

return NewSPRFilterFromInputs(inputs)
}
16 changes: 1 addition & 15 deletions http/intersects.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,7 @@ func IntersectsHandler(i pip_index.Index, idx *index.Indexer, opts *IntersectsHa
return
}

inputs, err := filter.NewSPRInputs()

if err != nil {
gohttp.Error(rsp, err.Error(), gohttp.StatusBadRequest)
return
}

inputs.Placetypes = query["placetype"]
inputs.IsCurrent = query["is_current"]
inputs.IsDeprecated = query["is_deprecated"]
inputs.IsCeased = query["is_ceased"]
inputs.IsSuperseded = query["is_superseded"]
inputs.IsSuperseding = query["is_superseding"]

filters, err := filter.NewSPRFilterFromInputs(inputs)
filters, err := filter.NewSPRFilterFromQuery(query)

if err != nil {
gohttp.Error(rsp, err.Error(), gohttp.StatusBadRequest)
Expand Down

0 comments on commit 28a1c72

Please sign in to comment.