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.

issue.go 936 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package convert
  5. import (
  6. "code.gitea.io/gitea/models"
  7. api "code.gitea.io/gitea/modules/structs"
  8. )
  9. // ToTrackedTime converts TrackedTime to API format
  10. func ToTrackedTime(t *models.TrackedTime) (apiT *api.TrackedTime) {
  11. apiT = &api.TrackedTime{
  12. ID: t.ID,
  13. IssueID: t.IssueID,
  14. UserID: t.UserID,
  15. UserName: t.User.Name,
  16. Time: t.Time,
  17. Created: t.Created,
  18. }
  19. if t.Issue != nil {
  20. apiT.Issue = t.Issue.APIFormat()
  21. }
  22. if t.User != nil {
  23. apiT.UserName = t.User.Name
  24. }
  25. return
  26. }
  27. // ToTrackedTimeList converts TrackedTimeList to API format
  28. func ToTrackedTimeList(tl models.TrackedTimeList) api.TrackedTimeList {
  29. result := make([]*api.TrackedTime, 0, len(tl))
  30. for _, t := range tl {
  31. result = append(result, ToTrackedTime(t))
  32. }
  33. return result
  34. }