Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a072fee59 | ||
|
|
c4213e697d | ||
|
|
934a306bc9 | ||
|
|
82bdbb1f3b | ||
|
|
b090cb86a5 | ||
|
|
e42df54632 |
@@ -221,7 +221,27 @@ func (ntg NTGVision) SearchZips(zips []string) ([]Job, error) {
|
|||||||
return jobs, nil
|
return jobs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
switch now.Hour() {
|
||||||
|
case 9, 10, 11, 12, 13, 14, 15, 16:
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (ntg NTGVision) SearchStates(states []config.State) ([]Job, error) {
|
func (ntg NTGVision) SearchStates(states []config.State) ([]Job, error) {
|
||||||
|
if !ntg.workingHours(time.Now()) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
rc, err := ntg.searcher.searchStates(states)
|
rc, err := ntg.searcher.searchStates(states)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -334,7 +354,7 @@ func (ntg NTGVision) _searchStates(states []config.State) (io.ReadCloser, error)
|
|||||||
request2, _ := ntg.newRequest(states)
|
request2, _ := ntg.newRequest(states)
|
||||||
requestb, _ := ioutil.ReadAll(request2.Body)
|
requestb, _ := ioutil.ReadAll(request2.Body)
|
||||||
logtr.Debugf("ntg auth bad status: url=%s, status=%v, body=%s, headers=%+v, request=%+v, requestb=%s", request.URL.String(), resp.StatusCode, b, resp.Header, request2, requestb)
|
logtr.Debugf("ntg auth bad status: url=%s, status=%v, body=%s, headers=%+v, request=%+v, requestb=%s", request.URL.String(), resp.StatusCode, b, resp.Header, request2, requestb)
|
||||||
if resp.StatusCode > 400 && resp.StatusCode < 404 {
|
if resp.StatusCode > 400 && resp.StatusCode < 404 || resp.StatusCode == 417 { // TODO wtf is 417 for
|
||||||
logtr.Debugf("ntg auth bad status: err no auth")
|
logtr.Debugf("ntg auth bad status: err no auth")
|
||||||
return nil, ErrNoAuth
|
return nil, ErrNoAuth
|
||||||
}
|
}
|
||||||
|
|||||||
16
broker/ntgvision_test.go
Normal file
16
broker/ntgvision_test.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package broker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestWorkingHoursNTG(t *testing.T) {
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
if ntg.workingHours(time.Date(2022, 1, 27, 23, 0, 0, 0, time.FixedZone("MST", -7*60*60))) {
|
||||||
|
t.Fatal("midnight MST ok")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
todo:
|
todo:
|
||||||
- fast exact does not use ID in UID because they spammy
|
|
||||||
- from states to zip codes w/ range
|
|
||||||
- modify old items once no longer available; drop stale jobs good candidate but requires new matrix interaction
|
|
||||||
- more than NTG; blue one
|
- more than NTG; blue one
|
||||||
- !states emits current state
|
- !states emits current state
|
||||||
- test each !command callbacks to matrix
|
- test each !command callbacks to matrix
|
||||||
@@ -14,7 +11,11 @@ todo:
|
|||||||
subtasks:
|
subtasks:
|
||||||
- banlist criteria like vendors, brokers, metadata
|
- banlist criteria like vendors, brokers, metadata
|
||||||
- set up copy for caleb, broc
|
- set up copy for caleb, broc
|
||||||
|
- move from main() and make more functions
|
||||||
done:
|
done:
|
||||||
|
- modify old items once no longer available; drop stale jobs good candidate but requires new matrix interaction
|
||||||
|
- from states to zip codes w/ range
|
||||||
|
- fast exact does not use ID in UID because they spammy
|
||||||
- fast exact is dumb or...?
|
- fast exact is dumb or...?
|
||||||
- try search ntg by autoinc?
|
- try search ntg by autoinc?
|
||||||
- TEST. Just like, refactor and test to shit.
|
- TEST. Just like, refactor and test to shit.
|
||||||
|
|||||||
Reference in New Issue
Block a user