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

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. NumRepoPublic int64 `xorm:"NOT NULL DEFAULT 0"`
  40. NumRepoPrivate int64 `xorm:"NOT NULL DEFAULT 0"`
  41. NumRepoFork int64 `xorm:"NOT NULL DEFAULT 0"`
  42. NumRepoMirror int64 `xorm:"NOT NULL DEFAULT 0"`
  43. NumRepoSelf int64 `xorm:"NOT NULL DEFAULT 0"`
  44. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
  45. UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
  46. }
  47. func DeleteSummaryStatisticDaily(date string) error {
  48. sess := xStatistic.NewSession()
  49. defer sess.Close()
  50. if err := sess.Begin(); err != nil {
  51. return fmt.Errorf("Begin: %v", err)
  52. }
  53. if _, err := sess.Where("date = ?", date).Delete(&SummaryStatistic{}); err != nil {
  54. return fmt.Errorf("Delete: %v", err)
  55. }
  56. if err := sess.Commit(); err != nil {
  57. sess.Close()
  58. return fmt.Errorf("Commit: %v", err)
  59. }
  60. sess.Close()
  61. return nil
  62. }
  63. func InsertSummaryStatistic(summaryStatistic *SummaryStatistic) (int64, error) {
  64. return xStatistic.Insert(summaryStatistic)
  65. }