-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shows total tracked time in issue and milestone list #3341
Changes from 2 commits
72c4296
1c0201f
1875038
b849f54
fda4dd4
983c1e1
707f3db
26a1e02
67be8bd
f1cfe62
770fea4
3c8507a
c5c812c
e92cc12
8481f2d
4cac53e
79dc9d8
421cbfb
1077882
9bb7714
0143b50
2f6a6fd
2d13376
a87698b
ec0d41c
856087e
02dc1cf
9508985
0ba269b
70e9bbd
221a327
90658cc
ca5243c
d623780
6a97bf7
62f9962
2835f08
526f7db
e9562ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,24 @@ func init() { | |
issueTasksDonePat = regexp.MustCompile(issueTasksDoneRegexpStr) | ||
} | ||
|
||
func (issue *Issue) totalTimes(e Engine) (string, error) { | ||
times, err := GetTrackedTimes(FindTrackedTimesOptions{IssueID: issue.ID}) | ||
if err != nil { | ||
return "", err | ||
} | ||
var totalTime int64 | ||
for _, trackedTime := range times { | ||
totalTime += trackedTime.Time | ||
} | ||
return secToTime(totalTime), nil | ||
} | ||
|
||
// TotalTimes returns the total amount of tracked time for the issue | ||
func (issue *Issue) TotalTimes() string { | ||
times, _ := issue.totalTimes(x) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error should be at least logged |
||
return times | ||
} | ||
|
||
func (issue *Issue) loadRepo(e Engine) (err error) { | ||
if issue.Repo == nil { | ||
issue.Repo, err = getRepositoryByID(e, issue.RepoID) | ||
|
@@ -78,6 +96,14 @@ func (issue *Issue) loadRepo(e Engine) (err error) { | |
return nil | ||
} | ||
|
||
// IsTimetrackerEnabled returns true if the repo enables timetracking | ||
func (issue *Issue) IsTimetrackerEnabled() bool { | ||
if issue.loadRepo(x) != nil { | ||
return false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If error is ignored than at least it should be logged |
||
} | ||
return issue.Repo.IsTimetrackerEnabled() | ||
} | ||
|
||
// GetPullRequest returns the issue pull request | ||
func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) { | ||
if !issue.IsPull { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ | |
<span class="issue-stats"> | ||
<i class="octicon octicon-issue-opened"></i> {{$.i18n.Tr "repo.issues.open_tab" .NumOpenIssues}} | ||
<i class="octicon octicon-issue-closed"></i> {{$.i18n.Tr "repo.issues.close_tab" .NumClosedIssues}} | ||
{{if and .TotalTimes .MustGetRepo.IsTimetrackerEnabled}}<i class="octicon octicon-clock"></i> {{.TotalTimes}}{{end}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same problem here as it was with issue list (each milestone queried even if time tracking disabled) and also each milestone queried separately |
||
</span> | ||
</div> | ||
{{if $.IsRepositoryWriter}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,10 @@ | |
<span class="comment ui right"><i class="octicon octicon-comment"></i> {{.NumComments}}</span> | ||
{{end}} | ||
|
||
{{if and .IsTimetrackerEnabled .TotalTimes}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Result of |
||
<span class="comment ui right"><i class="octicon octicon-clock"></i> {{.TotalTimes}}</span> | ||
{{end}} | ||
|
||
<p class="desc"> | ||
{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} | ||
{{if .Assignee}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to select total time from database already as single value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would mean a higher maintenance effort, wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reuse
FindTrackedTimesOptions
and usex.Where(options.ToCond()).Sum(&TrackedTime{}, "time")