ntg job info formatting
This commit is contained in:
@@ -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()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user