Compare commits

..

22 Commits

Author SHA1 Message Date
bel
cf34889bef little 2022-01-30 08:43:57 -07:00
bel
4a25e7dc0f make working hours, weekdays configurable by impl ntg 2022-01-30 08:34:14 -07:00
bel
93d74fb9e1 add ntg configurable work hours, weekdays 2022-01-30 08:29:06 -07:00
bel
0ded04f072 cache last ntg result for off hours 2022-01-29 18:59:16 -07:00
bel
ff1f62def9 Merge branch 'master' of http://gogs.scratch.com:59515/bel/truckstop 2022-01-29 18:44:21 -07:00
bel
72c6ef9619 fuck backwards bool 2022-01-29 18:44:13 -07:00
bel
546805cd71 log 2022-01-29 18:40:13 -07:00
Bel LaPointe
02bbfd6fd9 todo 2022-01-27 20:18:13 -07:00
Bel LaPointe
9e24ca3c65 fix offset to not need system timezone 2022-01-27 20:04:31 -07:00
Bel LaPointe
6551fb906d only do ntgvision searches 9-4 EST because 417s mean unauth until forced pw reset 2022-01-27 19:53:50 -07:00
Bel LaPointe
5d4677ab5c accept !radius for miles radius search 2022-01-27 19:21:03 -07:00
Bel LaPointe
c40b99a8d8 include one very nice log 2022-01-27 19:00:40 -07:00
Bel LaPointe
d1ca69f533 remove unwanted from help, only print !zip or !state as configured 2022-01-27 18:53:56 -07:00
Bel LaPointe
6f5a928e73 fix typo in config.json for == in query 2022-01-27 18:49:05 -07:00
Bel LaPointe
521dc4ce77 debug to verbose logs 2022-01-27 18:46:59 -07:00
Bel LaPointe
dbf4a7304f whoosp backwards if body 2022-01-27 18:41:58 -07:00
Bel LaPointe
8768857fbe job filters by zip or state depending on config 2022-01-27 18:35:40 -07:00
Bel LaPointe
2b420252d5 support logging zip changes 2022-01-27 18:27:01 -07:00
Bel LaPointe
64f1488a91 main will search zips if Broker.UseZips, ntg does its own filtering by city-state dist from search-zips 2022-01-27 18:20:52 -07:00
Bel LaPointe
00368c50ff ntgvision maps zips to states then does same query 2022-01-27 18:14:49 -07:00
Bel LaPointe
a3b8d5a6b2 impl and test zip.Get, MilesTo, GetStatesWithin, FromCityState 2022-01-27 18:11:11 -07:00
Bel LaPointe
ae7b834599 impl zip.Get for translating zip to info and calc dist 2022-01-27 17:58:00 -07:00
7 changed files with 38 additions and 33129 deletions

View File

@@ -224,14 +224,26 @@ func (ntg NTGVision) SearchZips(zips []string) ([]Job, error) {
func (ntg NTGVision) workingHours(now time.Time) bool {
// TODO assert M-F 9-4 EST
now = now.In(time.FixedZone("EST", -5*60*60))
logtr.Debugf("ntg.workingHours: %s: weekday=%v (sun=%v, sat=%v), hour=%v (ok=9..16)", now.String(), now.Weekday(), time.Sunday, time.Saturday, now.Hour())
switch now.Weekday() {
case time.Sunday, time.Saturday:
working := config.Get().Brokers.NTG.Working
logtr.Debugf("ntg.workingHours: now=%s, weekday=%v, hour=%v (ok=%+v)", now.String(), now.Weekday(), now.Hour(), working)
if ok := func() bool {
for _, hr := range working.Hours {
if now.Hour() == hr {
return true
}
}
return false
}(); !ok {
return false
}
switch now.Hour() {
case 9, 10, 11, 12, 13, 14, 15, 16:
default:
if ok := func() bool {
for _, weekday := range working.Weekdays {
if now.Weekday() == time.Weekday(weekday) {
return true
}
}
return false
}(); !ok {
return false
}
return true

View File

@@ -1,11 +1,17 @@
package broker
import (
"local/truckstop/config"
"os"
"testing"
"time"
)
func TestWorkingHoursNTG(t *testing.T) {
os.Setenv("CONFIG", "../config.json")
if err := config.Refresh(nil); err != nil {
t.Fatal(err)
}
ntg := NTGVision{}
if !ntg.workingHours(time.Date(2022, 1, 27, 12, 0, 0, 0, time.FixedZone("MST", -7*60*60))) {
t.Fatal("noon MST not ok")

View File

@@ -79,6 +79,10 @@
"UseZips": true,
"RadiusMiles": 200,
"NTG": {
"Working": {
"Hours": [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
"Weekdays": [1, 2, 3, 4, 5]
},
"Enabled": false,
"JobInfo": true,
"Mock": true,

View File

@@ -83,6 +83,10 @@
"Password": "p"
},
"NTG": {
"Working": {
"Hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
"Weekdays": [0, 1, 2, 3, 4, 5, 6]
},
"Enabled": true,
"JobInfo": true,
"Mock": true,

View File

@@ -67,6 +67,10 @@ type Config struct {
UseZips bool
RadiusMiles int
NTG struct {
Working struct {
Hours []int
Weekdays []int
}
Enabled bool
JobInfo bool
Mock bool

View File

@@ -371,7 +371,7 @@ func __main() error {
logtr.Errorf("failed _main: %v", err)
}
if config.Get().Once {
time.Sleep(3 * time.Second)
time.Sleep(10 * time.Second)
return err
}
if err != nil {

File diff suppressed because it is too large Load Diff