aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_stopwatch.go
diff options
context:
space:
mode:
authorJonas Franz <info@jonasfranz.software>2018-04-29 07:58:47 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2018-04-29 13:58:47 +0800
commit8d5f58d8347196fca04fdf3a22d021d09d15e37f (patch)
tree4db9aabfec9a274b945dc3835d261c3267440ee3 /models/issue_stopwatch.go
parente3028d124f864b0ed2563cd0fea8b24612eb64bb (diff)
downloadgitea-8d5f58d8347196fca04fdf3a22d021d09d15e37f.tar.gz
gitea-8d5f58d8347196fca04fdf3a22d021d09d15e37f.zip
Shows total tracked time in issue and milestone list (#3341)
* Show total tracked time in issue and milestone list Show total tracked time at issue page Signed-off-by: Jonas Franz <info@jonasfranz.software> * Optimizing TotalTimes by using SumInt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fixing wrong total times for milestones caused by a missing JOIN Adding unit tests for total times Signed-off-by: Jonas Franz <info@jonasfranz.software> * Logging error instead of ignoring it Signed-off-by: Jonas Franz <info@jonasfranz.software> * Correcting spelling mistakes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Change error message to a short version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add error handling to TotalTimes Add variable for totalTimes Signed-off-by: Jonas Franz <info@jonasfranz.de> * Introduce TotalTrackedTimes as variable of issue 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> * Fixed test + gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Load TotalTrackedTimes via MilestoneList instead of single requests Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add documentation for MilestoneList Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add documentation for MilestoneList Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Change comment from SQL query to description Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit test by using int64 instead of int Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit test by using int64 instead of int Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if timetracker is enabled Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by enabling timetracking Signed-off-by: Jonas Franz <info@jonasfranz.de>
Diffstat (limited to 'models/issue_stopwatch.go')
-rw-r--r--models/issue_stopwatch.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/models/issue_stopwatch.go b/models/issue_stopwatch.go
index 92b1bb9a5f..178b76c5dd 100644
--- a/models/issue_stopwatch.go
+++ b/models/issue_stopwatch.go
@@ -69,7 +69,7 @@ func CreateOrStopIssueStopwatch(user *User, issue *Issue) error {
Doer: user,
Issue: issue,
Repo: issue.Repo,
- Content: secToTime(timediff),
+ Content: SecToTime(timediff),
Type: CommentTypeStopTracking,
}); err != nil {
return err
@@ -124,7 +124,8 @@ func CancelStopwatch(user *User, issue *Issue) error {
return nil
}
-func secToTime(duration int64) string {
+// SecToTime converts an amount of seconds to a human-readable string (example: 66s -> 1min 6s)
+func SecToTime(duration int64) string {
seconds := duration % 60
minutes := (duration / (60)) % 60
hours := duration / (60 * 60)