ntgvision maps zips to states then does same query
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"local/truckstop/config"
|
"local/truckstop/config"
|
||||||
"local/truckstop/logtr"
|
"local/truckstop/logtr"
|
||||||
|
"local/truckstop/zip"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -188,7 +189,22 @@ func (ntg NTGVision) searchJob(id int64) (ntgVisionJobInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ntg NTGVision) SearchZips(zips []string) ([]Job, 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) {
|
func (ntg NTGVision) SearchStates(states []config.State) ([]Job, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user