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.

summary_statistic.go 2.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package models
  2. import (
  3. "fmt"
  4. "code.gitea.io/gitea/modules/timeutil"
  5. )
  6. var DomainMap = map[string]int{
  7. "大模型": 0,
  8. "ai开发工具": 1,
  9. "计算机视觉": 2,
  10. "自然语言处理": 3,
  11. "机器学习": 4,
  12. "神经网络": 5,
  13. "自动驾驶": 6,
  14. "机器人": 7,
  15. "联邦学习": 8,
  16. "数据挖掘": 9,
  17. "risc-v开发": 10,
  18. }
  19. type SummaryStatistic struct {
  20. ID int64 `xorm:"pk autoincr"`
  21. Date string `xorm:"unique(s) NOT NULL"`
  22. NumUsers int64 `xorm:"NOT NULL DEFAULT 0"`
  23. RepoSize int64 `xorm:"NOT NULL DEFAULT 0"`
  24. DatasetSize int64 `xorm:"NOT NULL DEFAULT 0"`
  25. NumOrganizations int64 `xorm:"NOT NULL DEFAULT 0"`
  26. NumModels int64 `xorm:"NOT NULL DEFAULT 0"`
  27. NumRepos int64 `xorm:"NOT NULL DEFAULT 0"`
  28. NumRepoBigModel int `xorm:"NOT NULL DEFAULT 0"`
  29. NumRepoAI int `xorm:"NOT NULL DEFAULT 0"`
  30. NumRepoVision int `xorm:"NOT NULL DEFAULT 0"`
  31. NumRepoNLP int `xorm:"NOT NULL DEFAULT 0"`
  32. NumRepoML int `xorm:"NOT NULL DEFAULT 0"`
  33. NumRepoNN int `xorm:"NOT NULL DEFAULT 0"`
  34. NumRepoAutoDrive int `xorm:"NOT NULL DEFAULT 0"`
  35. NumRepoRobot int `xorm:"NOT NULL DEFAULT 0"`
  36. NumRepoLeagueLearn int `xorm:"NOT NULL DEFAULT 0"`
  37. NumRepoDataMining int `xorm:"NOT NULL DEFAULT 0"`
  38. NumRepoRISC int `xorm:"NOT NULL DEFAULT 0"`
  39. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
  40. UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
  41. }
  42. func DeleteSummaryStatisticDaily(date string) error {
  43. sess := xStatistic.NewSession()
  44. defer sess.Close()
  45. if err := sess.Begin(); err != nil {
  46. return fmt.Errorf("Begin: %v", err)
  47. }
  48. if _, err := sess.Where("date = ?", date).Delete(&SummaryStatistic{}); err != nil {
  49. return fmt.Errorf("Delete: %v", err)
  50. }
  51. if err := sess.Commit(); err != nil {
  52. sess.Close()
  53. return fmt.Errorf("Commit: %v", err)
  54. }
  55. sess.Close()
  56. return nil
  57. }
  58. func InsertSummaryStatistic(summaryStatistic *SummaryStatistic) (int64, error) {
  59. return xStatistic.Insert(summaryStatistic)
  60. }