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.

dataset.go 1.0 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package dataset
  2. import (
  3. "strings"
  4. "code.gitea.io/gitea/models"
  5. )
  6. func GetResourceType(cloudbrainType int) string {
  7. if cloudbrainType == 0 {
  8. return "CPU/GPU"
  9. } else {
  10. return "NPU"
  11. }
  12. }
  13. func GetStatusText(isPrivate bool) string {
  14. if isPrivate {
  15. return "dataset.private"
  16. } else {
  17. return "dataset.public"
  18. }
  19. }
  20. func IsShowDataSetOfCurrentRepo(repoID int64) bool {
  21. repo := models.Repository{
  22. ID: repoID,
  23. }
  24. dataset, _ := models.GetDatasetByRepo(&repo)
  25. if dataset != nil {
  26. return true
  27. }
  28. if models.HasReferenceDataset(repoID) {
  29. return false
  30. }
  31. return true
  32. }
  33. func GetFilterDeletedAttachments(uuids string) (string, string) {
  34. attachments, err := models.GetAttachmentsByUUIDs(strings.Split(uuids, ";"))
  35. if err != nil {
  36. return "", ""
  37. }
  38. uuidR := ""
  39. filenames := ""
  40. for i, attachment := range attachments {
  41. if i == 0 {
  42. uuidR += attachment.UUID
  43. filenames += attachment.Name
  44. } else {
  45. uuidR += ";" + attachment.UUID
  46. filenames += ";" + attachment.Name
  47. }
  48. }
  49. return uuidR, filenames
  50. }