job filters by zip or state depending on config

Bel LaPointe 2022-01-27 18:35:40 -07:00
parent 211ef64261
commit e916b5abfc
2 changed files with 15 additions and 6 deletions

View File

@ -4,7 +4,7 @@ import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"local/truckstop/config" "local/truckstop/config"
"local/truckstop/logtr" "local/truckstop/zip"
"strings" "strings"
"time" "time"
) )
@ -86,9 +86,17 @@ func (j Job) FormatMultilineText() string {
} }
out := "" out := ""
clients := config.Clients(j.Pickup.Date) 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 { for k := range clients {
logtr.Debugf("job multiline: %+v contains %s then use %v", clients[k].States, j.Pickup.State, k) should := strings.Contains(fmt.Sprint(clients[k].States), j.Pickup.State)
if 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 { if len(out) > 0 {
out += "\n" out += "\n"
} }

View File

@ -49,7 +49,8 @@
"NC" "NC"
], ],
"Zips": [ "Zips": [
"27006" "27006",
"84058"
], ],
"IDs": { "IDs": {
"Matrix": "@bel:m.bltrucks.top" "Matrix": "@bel:m.bltrucks.top"
@ -78,14 +79,14 @@
"RadiusMiles": 100, "RadiusMiles": 100,
"FastExact": { "FastExact": {
"Enabled": true, "Enabled": true,
"Mock": true, "Mock": false,
"Username": "birdman", "Username": "birdman",
"Password": "166647" "Password": "166647"
}, },
"NTG": { "NTG": {
"Enabled": false, "Enabled": false,
"JobInfo": true, "JobInfo": true,
"Mock": true, "Mock": false,
"LoadPageURIFormat": "https://ntgvision.com/LoadDetails?loadId=%d", "LoadPageURIFormat": "https://ntgvision.com/LoadDetails?loadId=%d",
"LoadPageAPIURIFormat": "https://ntgvision.com/api/v1/load/LoadDetails?loadId==%d", "LoadPageAPIURIFormat": "https://ntgvision.com/api/v1/load/LoadDetails?loadId==%d",
"Username": "noeasyrunstrucking@gmail.com", "Username": "noeasyrunstrucking@gmail.com",