ntg job info formatting
parent
edf95d292a
commit
a6ae4b9617
|
|
@ -45,14 +45,37 @@ type ntgVisionJobInfo struct {
|
|||
} `json:"stopinfos"`
|
||||
PayUpTo float32 `json:"payUpTo"`
|
||||
LoadState string `json:"loadStatus"`
|
||||
CanBidNow bool `json:"canBidNow"`
|
||||
//CanBidNow bool `json:"canBidNow"`
|
||||
}
|
||||
|
||||
func (ji ntgVisionJobInfo) IsZero() bool {
|
||||
return len(ji.StopsInfo) == 0 && ji.PayUpTo == 0 && ji.LoadState == ""
|
||||
}
|
||||
|
||||
func (ji ntgVisionJobInfo) String() string {
|
||||
if ji.IsZero() {
|
||||
return ""
|
||||
}
|
||||
out := fmt.Sprintf("Pays:%v Auction:%v", ji.PayUpTo, ji.LoadState)
|
||||
if len(ji.StopsInfo) != 2 {
|
||||
return out
|
||||
}
|
||||
return fmt.Sprintf(
|
||||
"%s Pickup:{Hours:%s Notes:%s, DropTrailer:%s} Dropoff:{Appointment:%s Notes:%s}",
|
||||
out,
|
||||
ji.StopsInfo[0].StopHours,
|
||||
ji.StopsInfo[0].Instructions,
|
||||
ji.StopsInfo[0].IsDropTrailer,
|
||||
ji.StopsInfo[1].AppointmentTime,
|
||||
ji.StopsInfo[1].Instructions,
|
||||
)
|
||||
}
|
||||
|
||||
func (ntgJob *ntgVisionJob) JobInfo() (ntgVisionJobInfo, error) {
|
||||
if !config.Get().Brokers.NTG.JobInfo {
|
||||
return ntgJob.jobinfo, nil
|
||||
}
|
||||
if fmt.Sprint(ntgJob.jobinfo) != fmt.Sprint(ntgVisionJobInfo{}) {
|
||||
if !ntgJob.jobinfo.IsZero() {
|
||||
return ntgJob.jobinfo, nil
|
||||
}
|
||||
ji, err := ntgJob.jobInfo()
|
||||
|
|
@ -113,7 +136,7 @@ func (ntgJob *ntgVisionJob) Job() Job {
|
|||
log.Printf("failed to get jobinfo: %v", err)
|
||||
return nil
|
||||
}
|
||||
return jobInfo
|
||||
return jobInfo.String()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
"Matrix": {
|
||||
"ReceiveEnabled": true,
|
||||
"Mock": false,
|
||||
"Continuation": "1342",
|
||||
"Continuation": "1350",
|
||||
"Homeserver": "https://m.bltrucks.top",
|
||||
"Username": "@bot.m.bltrucks.top",
|
||||
"Token": "mvDWB96KXMF8XhOam8EC5XVdQvSEw0CDeClcSWocBcYkwZX3FPNWZ5uOnQk2EmT1cjpzfeuD7gDYPPjOuyZlI3bE9TE35UjNOlZgi0Tugm25s91iVsbIF6kMZsCIhVMSmEf6w3jxX6wQYOWvmDZ4mu6f5c8wr221EMDcOpEzQV09d1zuBSWgKLBgjqAkYHJZ5dTRIWpEDpPgujhOFZa2ld1HiAOxrJKlIrlfDBN0CUsTlGOGplujDAr4VtpFzNRS",
|
||||
|
|
|
|||
Loading…
Reference in New Issue