Repository navigation
Shows total tracked time in issue and milestone list - #3341
Conversation
Show total tracked time at issue page Signed-off-by: Jonas Franz <info@jonasfranz.software>
| } | ||
|
|
||
| func (issue *Issue) totalTimes(e Engine) (string, error) { | ||
| times, err := GetTrackedTimes(FindTrackedTimesOptions{IssueID: issue.ID}) |
There was a problem hiding this comment.
It would be better to select total time from database already as single value
There was a problem hiding this comment.
This would mean a higher maintenance effort, wouldn't it?
There was a problem hiding this comment.
Just reuse FindTrackedTimesOptions and use x.Where(options.ToCond()).Sum(&TrackedTime{}, "time")
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Codecov Report
@@ Coverage Diff @@
## master #3341 +/- ##
=========================================
+ Coverage 23% 23.3% +0.29%
=========================================
Files 126 126
Lines 24892 24999 +107
=========================================
+ Hits 5726 5825 +99
+ Misses 18289 18286 -3
- Partials 877 888 +11
Continue to review full report at Codecov.
|
|
I don't know if this can be done with xorm but for list it would be better to load it with one select (group by and sum). Might be that @lunny can answer that |
|
If you want join, just add
|
|
@lunny I am using this JOIN already (https://github.com/JonasFranzDEV/gitea/blob/187503832073280c4c994753778e1d69c307a000/models/issue_tracked_time.go#L71). I think that @lafriks meant that it would be better to make a query for everything like listing issues and sum of tracked time. |
Adding unit tests for total times Signed-off-by: Jonas Franz <info@jonasfranz.software>
| // 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.
If error is ignored than at least it should be logged
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Signed-off-by: Jonas Franz <info@jonasfranz.software>
|
LGTM |
|
|
||
| // 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.
Error should be at least logged
| <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.
Result of .TotalTimes be assigned probably to some variable otherwise currently if there is value this query will be executed twice
Add variable for totalTimes Signed-off-by: Jonas Franz <info@jonasfranz.de>
Load TotalTrackedTimes by loading attributes of IssueList Load TotalTrackedTimes by loading attributes of single issue Add Sec2Time as helper to use it in templates Signed-off-by: Jonas Franz <info@jonasfranz.software>
|
@JonasFranzDEV in model just like IssueList |
Signed-off-by: Jonas Franz <info@jonasfranz.software>
|
@lafriks Done |
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Signed-off-by: Jonas Franz <info@jonasfranz.software>
| } | ||
| var trackedTimes = make(map[int64]int64, len(milestones)) | ||
|
|
||
| // SELECT milestone_id, sum(time) as time FROM `issue` |
Signed-off-by: Jonas Franz <info@jonasfranz.software>
|
Need to resolve conflicts but otherwise LG-TM |
|
@lafriks Done |
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Signed-off-by: Jonas Franz <info@jonasfranz.software>
| <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 .TotalTrackedTime}}<i class="octicon octicon-clock"></i> {{.TotalTrackedTime|Sec2Time}}{{end}} |
There was a problem hiding this comment.
This should probably also change to same as in issues.tmpl: {{if and .IsTimetrackerEnabled .TotalTrackedTime}}
There was a problem hiding this comment.
No, because .TotalTrackedTime is zero if timetracker is disabled because TotalTrackedTime is only loaded if it is enabled. (https://github.com/go-gitea/gitea/pull/3341/files#diff-ece22e0fe138da6e0fe0f25213406313R1142)
There was a problem hiding this comment.
Than probably there also needs to be such check added so that it would behave same in both places: https://github.com/JonasFranzDEV/gitea/blob/d6237809c472de482cc31fb954af1a8fd6ef54b4/models/issue.go#L248
Signed-off-by: Jonas Franz <info@jonasfranz.software>
Signed-off-by: Jonas Franz <info@jonasfranz.de>
|
@lafriks Build failure is not related to this PR, could you please merge? |
* SECURITY * Limit uploaded avatar image-size to 4096x3072 by default (go-gitea#4353) * Do not allow to reuse TOTP passcode (go-gitea#3878) * FEATURE * Add cli commands to regen hooks & keys (go-gitea#3979) * Add support for FIDO U2F (go-gitea#3971) * Added user language setting (go-gitea#3875) * LDAP Public SSH Keys synchronization (go-gitea#1844) * Add topic support (go-gitea#3711) * Multiple assignees (go-gitea#3705) * Add protected branch whitelists for merging (go-gitea#3689) * Global code search support (go-gitea#3664) * Add label descriptions (go-gitea#3662) * Add issue search via API (go-gitea#3612) * Add repository setting to enable/disable health checks (go-gitea#3607) * Emoji Autocomplete (go-gitea#3433) * Implements generator cli for secrets (go-gitea#3531) * ENHANCEMENT * Add more webhooks support and refactor webhook templates directory (go-gitea#3929) * Add new option to allow only OAuth2/OpenID user registration (go-gitea#3910) * Add option to use paged LDAP search when synchronizing users (go-gitea#3895) * Symlink icons (go-gitea#1416) * Improve release page UI (go-gitea#3693) * Add admin dashboard option to run health checks (go-gitea#3606) * Add branch link in branch list (go-gitea#3576) * Reduce sql query times in retrieveFeeds (go-gitea#3547) * Option to enable or disable swagger endpoints (go-gitea#3502) * Add missing licenses (go-gitea#3497) * Reduce repo indexer disk usage (go-gitea#3452) * Enable caching on assets and avatars (go-gitea#3376) * Add repository search ordered by stars/forks. Forks column in admin repo list (go-gitea#3969) * Add Environment Variables to Docker template (go-gitea#4012) * LFS: make HTTP auth period configurable (go-gitea#4035) * Add config path as an optionial flag when changing pass via CLI (go-gitea#4184) * Refactor User Settings sections (go-gitea#3900) * Allow square brackets in external issue patterns (go-gitea#3408) * Add Attachment API (go-gitea#3478) * Add EnableTimetracking option to app settings (go-gitea#3719) * Add config option to enable or disable log executed SQL (go-gitea#3726) * Shows total tracked time in issue and milestone list (go-gitea#3341) * TRANSLATION * Improve English grammar and consistency (go-gitea#3614) * DEPLOYMENT * Allow Gitea to run as different USER in Docker (go-gitea#3961) * Provide compressed release binaries (go-gitea#3991) * Sign release binaries (go-gitea#4188)
Fixes #3003 (partially)
Milestone List:

Issue List:

Issue Detail Page:
