-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move tracked time api convert to convert package (#9665)
- Loading branch information
1 parent
705b1e4
commit 4d06d10
Showing
3 changed files
with
44 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2020 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package convert | ||
|
||
import ( | ||
"code.gitea.io/gitea/models" | ||
api "code.gitea.io/gitea/modules/structs" | ||
) | ||
|
||
// ToTrackedTime converts TrackedTime to API format | ||
func ToTrackedTime(t *models.TrackedTime) (apiT *api.TrackedTime) { | ||
apiT = &api.TrackedTime{ | ||
ID: t.ID, | ||
IssueID: t.IssueID, | ||
UserID: t.UserID, | ||
UserName: t.User.Name, | ||
Time: t.Time, | ||
Created: t.Created, | ||
} | ||
if t.Issue != nil { | ||
apiT.Issue = t.Issue.APIFormat() | ||
} | ||
if t.User != nil { | ||
apiT.UserName = t.User.Name | ||
} | ||
return | ||
} | ||
|
||
// ToTrackedTimeList converts TrackedTimeList to API format | ||
func ToTrackedTimeList(tl models.TrackedTimeList) api.TrackedTimeList { | ||
result := make([]*api.TrackedTime, 0, len(tl)) | ||
for _, t := range tl { | ||
result = append(result, ToTrackedTime(t)) | ||
} | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters