job filters by zip or state depending on config
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"local/truckstop/config"
|
||||
"local/truckstop/logtr"
|
||||
"local/truckstop/zip"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -86,9 +86,17 @@ func (j Job) FormatMultilineText() string {
|
||||
}
|
||||
out := ""
|
||||
clients := config.Clients(j.Pickup.Date)
|
||||
useZip := config.Get().Brokers.UseZips
|
||||
zipRadius := config.Get().Brokers.RadiusMiles
|
||||
jobZip := zip.FromCityState(j.Pickup.City, j.Pickup.State)
|
||||
for k := range clients {
|
||||
logtr.Debugf("job multiline: %+v contains %s then use %v", clients[k].States, j.Pickup.State, k)
|
||||
if strings.Contains(fmt.Sprint(clients[k].States), j.Pickup.State) {
|
||||
should := strings.Contains(fmt.Sprint(clients[k].States), j.Pickup.State)
|
||||
if useZip {
|
||||
for _, z := range clients[k].Zips {
|
||||
should = should || zip.Get(z).MilesTo(jobZip) <= zipRadius
|
||||
}
|
||||
}
|
||||
if should {
|
||||
if len(out) > 0 {
|
||||
out += "\n"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user