ntgvision maps zips to states then does same query
parent
db289cb5c8
commit
d2cf8c74a2
|
|
@ -9,6 +9,7 @@ import (
|
|||
"io/ioutil"
|
||||
"local/truckstop/config"
|
||||
"local/truckstop/logtr"
|
||||
"local/truckstop/zip"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -188,7 +189,22 @@ func (ntg NTGVision) searchJob(id int64) (ntgVisionJobInfo, error) {
|
|||
}
|
||||
|
||||
func (ntg NTGVision) SearchZips(zips []string) ([]Job, error) {
|
||||
return nil, errors.New("not impl: ntg search zips")
|
||||
radius := config.Get().Brokers.RadiusMiles
|
||||
statesm := map[string]struct{}{}
|
||||
for _, z := range zips {
|
||||
somestates := zip.GetStatesWithin(zip.Get(z), radius)
|
||||
for _, state := range somestates {
|
||||
statesm[state] = struct{}{}
|
||||
}
|
||||
}
|
||||
states := make([]config.State, 0, len(statesm))
|
||||
for state := range statesm {
|
||||
states = append(states, config.State(state))
|
||||
}
|
||||
if len(states) == 0 {
|
||||
return nil, fmt.Errorf("failed to map zipcodes %+v to any states", zips)
|
||||
}
|
||||
return ntg.SearchStates(states)
|
||||
}
|
||||
|
||||
func (ntg NTGVision) SearchStates(states []config.State) ([]Job, error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue