File tree 2 files changed +24
-15
lines changed
2 files changed +24
-15
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ package issues
6
6
7
7
import (
8
8
"context"
9
+ "errors"
9
10
"time"
10
11
11
12
"code.gitea.io/gitea/models/db"
@@ -47,33 +48,42 @@ func (t *TrackedTime) LoadAttributes() (err error) {
47
48
}
48
49
49
50
func (t * TrackedTime ) loadAttributes (ctx context.Context ) (err error ) {
51
+ // Load the issue
50
52
if t .Issue == nil {
51
53
t .Issue , err = GetIssueByID (ctx , t .IssueID )
52
- if err != nil {
53
- return
54
+
55
+ if err != nil && ! errors .Is (err , util .ErrNotExist ) {
56
+ return err
54
57
}
58
+ }
59
+ // Now load the repo for the issue (which we may have just loaded)
60
+ if t .Issue != nil {
55
61
err = t .Issue .LoadRepo (ctx )
56
- if err != nil {
57
- return
62
+ if err != nil && ! errors . Is ( err , util . ErrNotExist ) {
63
+ return err
58
64
}
59
65
}
66
+ // Load the user
60
67
if t .User == nil {
61
68
t .User , err = user_model .GetUserByIDCtx (ctx , t .UserID )
62
69
if err != nil {
63
- return
70
+ if ! errors .Is (err , util .ErrNotExist ) {
71
+ return err
72
+ }
73
+ t .User = user_model .NewGhostUser ()
64
74
}
65
75
}
66
- return err
76
+ return nil
67
77
}
68
78
69
79
// LoadAttributes load Issue, User
70
- func (tl TrackedTimeList ) LoadAttributes () ( err error ) {
80
+ func (tl TrackedTimeList ) LoadAttributes () error {
71
81
for _ , t := range tl {
72
- if err = t .LoadAttributes (); err != nil {
82
+ if err : = t .LoadAttributes (); err != nil {
73
83
return err
74
84
}
75
85
}
76
- return err
86
+ return nil
77
87
}
78
88
79
89
// FindTrackedTimesOptions represent the filters for tracked times. If an ID is 0 it will be ignored.
Original file line number Diff line number Diff line change @@ -110,12 +110,11 @@ func ToAPIIssueList(il issues_model.IssueList) []*api.Issue {
110
110
// ToTrackedTime converts TrackedTime to API format
111
111
func ToTrackedTime (t * issues_model.TrackedTime ) (apiT * api.TrackedTime ) {
112
112
apiT = & api.TrackedTime {
113
- ID : t .ID ,
114
- IssueID : t .IssueID ,
115
- UserID : t .UserID ,
116
- UserName : t .User .Name ,
117
- Time : t .Time ,
118
- Created : t .Created ,
113
+ ID : t .ID ,
114
+ IssueID : t .IssueID ,
115
+ UserID : t .UserID ,
116
+ Time : t .Time ,
117
+ Created : t .Created ,
119
118
}
120
119
if t .Issue != nil {
121
120
apiT .Issue = ToAPIIssue (t .Issue )
You can’t perform that action at this time.
0 commit comments