task.go 940 B

1234567891011121314151617181920212223242526272829303132
  1. package archive
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/admin/main/videoup/model/archive"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _taskTooksByHalfHourSQL = "SELECT id,m50,m60,m80,m90,type,ctime,mtime FROM task_dispatch_took WHERE type=2 AND ctime>=? AND ctime<=? ORDER BY ctime ASC"
  10. )
  11. // TaskTooksByHalfHour get TaskTooks by half hour
  12. func (d *Dao) TaskTooksByHalfHour(c context.Context, stime time.Time, etime time.Time) (tooks []*archive.TaskTook, err error) {
  13. rows, err := d.rddb.Query(c, _taskTooksByHalfHourSQL, stime, etime)
  14. if err != nil {
  15. log.Error("d.TaskTooksByHalfHour.Query(%v,%v) error(%v)", stime, etime, err)
  16. return
  17. }
  18. defer rows.Close()
  19. for rows.Next() {
  20. took := &archive.TaskTook{}
  21. if err = rows.Scan(&took.ID, &took.M50, &took.M60, &took.M80, &took.M90, &took.TypeID, &took.Ctime, &took.Mtime); err != nil {
  22. log.Error("rows.Scan error(%v)", err)
  23. return
  24. }
  25. tooks = append(tooks, took)
  26. }
  27. return
  28. }