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 3.0 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package models
  2. import (
  3. "strconv"
  4. "time"
  5. "code.gitea.io/gitea/modules/timeutil"
  6. )
  7. // Cloudbrain statistic info of all CloudbrainTasks
  8. type CloudbrainStatistic struct {
  9. ID int64 `xorm:"pk autoincr" json:"-"`
  10. Date string `xorm:"unique(s) NOT NULL" json:"date"`
  11. NumDubugOne int64 `xorm:"NOT NULL DEFAULT 0" json:"numDubugOne"`
  12. NumBenchmarkOne int64 `xorm:"NOT NULL DEFAULT 0" json:"numBenchmarkOne"`
  13. NumTrainOne int64 `xorm:"NOT NULL DEFAULT 0" json:"numTrainOne"`
  14. NumDubugTwo int64 `xorm:"NOT NULL DEFAULT 0" json:"numDubugTwo"`
  15. NumTrainTwo int64 `xorm:"NOT NULL DEFAULT 0" json:"numTrainTwo"`
  16. NumInferenceTwo int64 `xorm:"NOT NULL DEFAULT 0" json:"numInferenceTwo"`
  17. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created" json:"-"`
  18. UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated" json:"-"`
  19. }
  20. func GenerateDebugOneCount(beginTime time.Time, endTime time.Time) (int64, error) {
  21. countSql := "SELECT count(*) FROM " +
  22. "public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  23. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  24. " and job_type ='" + string(JobTypeDebug) + "'" +
  25. " and type='" + strconv.Itoa(TypeCloudBrainOne) + "'"
  26. return x.SQL(countSql).Count()
  27. }
  28. func GenerateBenchmarkOneCount(beginTime time.Time, endTime time.Time) (int64, error) {
  29. countSql := "SELECT count(*) FROM " +
  30. "public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  31. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  32. " and job_type ='" + string(JobTypeBenchmark) + "'" +
  33. " and type='" + strconv.Itoa(TypeCloudBrainOne) + "'"
  34. return x.SQL(countSql).Count()
  35. }
  36. func GenerateDebugTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
  37. countSql := "SELECT count(*) FROM " +
  38. "public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  39. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  40. " and job_type ='" + string(JobTypeDebug) + "'" +
  41. " and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'"
  42. return x.SQL(countSql).Count()
  43. }
  44. func GenerateTrainTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
  45. countSql := "SELECT count(*) FROM " +
  46. "public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  47. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  48. " and job_type ='" + string(JobTypeTrain) + "'" +
  49. " and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'"
  50. return x.SQL(countSql).Count()
  51. }
  52. func GenerateInferenceTwoCount(beginTime time.Time, endTime time.Time) (int64, error) {
  53. countSql := "SELECT count(*) FROM " +
  54. "public.cloudbrain where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) +
  55. " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) +
  56. " and job_type ='" + string(JobTypeInference) + "'" +
  57. " and type='" + strconv.Itoa(TypeCloudBrainTwo) + "'"
  58. return x.SQL(countSql).Count()
  59. }