You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cloudbrain_static.go 2.0 kB

4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package models
  2. import (
  3. "strconv"
  4. "time"
  5. )
  6. func GenerateDebugOneCount(beginTime time.Time, endTime time.Time) (int64, error) {
  7. countSql := "SELECT count(*) FROM " +
  8. "public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  9. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  10. " and job_type=" + "DEBUG"
  11. return xStatistic.SQL(countSql).Count()
  12. }
  13. func GenerateBenchmarkOneCount(beginTime time.Time, endTime time.Time) (int64, error) {
  14. countSql := "SELECT count(*) FROM " +
  15. "SELECT job_id FROM cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  16. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  17. " and job_type=" + "BENCHMARK" +
  18. " and type=" + "0"
  19. return xStatistic.SQL(countSql).Count()
  20. }
  21. func GenerateDebugTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
  22. countSql := "SELECT count(*) FROM " +
  23. "SELECT job_id FROM cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  24. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  25. " and job_type=" + "DEBUG" +
  26. " and type=" + "2"
  27. return xStatistic.SQL(countSql).Count()
  28. }
  29. func GenerateTrainTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
  30. countSql := "SELECT count(*) FROM " +
  31. "SELECT job_id FROM cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  32. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  33. " and job_type=" + "TRAIN" +
  34. " and type=" + "1"
  35. return xStatistic.SQL(countSql).Count()
  36. }
  37. func GenerateInferenceTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
  38. countSql := "SELECT count(*) FROM " +
  39. "SELECT job_id FROM cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  40. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  41. " and job_type=" + "INFERENCE" +
  42. " and type=" + "1"
  43. return xStatistic.SQL(countSql).Count()
  44. }