From 2a2b0cb1d2f7de9dcdb8e84250bfb9ef501fd748 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 29 Sep 2023 14:04:14 +0100 Subject: [PATCH] rename TotalTimes() to TotalTimesForEachUser() (#27261) make function name more descriptive as it would otherwise imply it could be used for e.g. #26672 too ... --- *Sponsored by Kithara Software GmbH* --- models/issues/tracked_time.go | 4 ++-- models/issues/tracked_time_test.go | 10 +++++----- routers/web/repo/issue.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/models/issues/tracked_time.go b/models/issues/tracked_time.go index 58c6b775f..c51df627a 100644 --- a/models/issues/tracked_time.go +++ b/models/issues/tracked_time.go @@ -198,8 +198,8 @@ func addTime(ctx context.Context, user *user_model.User, issue *Issue, amount in return tt, db.Insert(ctx, tt) } -// TotalTimes returns the spent time in seconds for each user by an issue -func TotalTimes(options *FindTrackedTimesOptions) (map[*user_model.User]int64, error) { +// TotalTimesForEachUser returns the spent time in seconds for each user by an issue +func TotalTimesForEachUser(options *FindTrackedTimesOptions) (map[*user_model.User]int64, error) { trackedTimes, err := GetTrackedTimes(db.DefaultContext, options) if err != nil { return nil, err diff --git a/models/issues/tracked_time_test.go b/models/issues/tracked_time_test.go index caced78c9..24081f1bf 100644 --- a/models/issues/tracked_time_test.go +++ b/models/issues/tracked_time_test.go @@ -79,10 +79,10 @@ func TestGetTrackedTimes(t *testing.T) { assert.Len(t, times, 0) } -func TestTotalTimes(t *testing.T) { +func TestTotalTimesForEachUser(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - total, err := issues_model.TotalTimes(&issues_model.FindTrackedTimesOptions{IssueID: 1}) + total, err := issues_model.TotalTimesForEachUser(&issues_model.FindTrackedTimesOptions{IssueID: 1}) assert.NoError(t, err) assert.Len(t, total, 1) for user, time := range total { @@ -90,7 +90,7 @@ func TestTotalTimes(t *testing.T) { assert.EqualValues(t, 400, time) } - total, err = issues_model.TotalTimes(&issues_model.FindTrackedTimesOptions{IssueID: 2}) + total, err = issues_model.TotalTimesForEachUser(&issues_model.FindTrackedTimesOptions{IssueID: 2}) assert.NoError(t, err) assert.Len(t, total, 2) for user, time := range total { @@ -103,7 +103,7 @@ func TestTotalTimes(t *testing.T) { } } - total, err = issues_model.TotalTimes(&issues_model.FindTrackedTimesOptions{IssueID: 5}) + total, err = issues_model.TotalTimesForEachUser(&issues_model.FindTrackedTimesOptions{IssueID: 5}) assert.NoError(t, err) assert.Len(t, total, 1) for user, time := range total { @@ -111,7 +111,7 @@ func TestTotalTimes(t *testing.T) { assert.EqualValues(t, 1, time) } - total, err = issues_model.TotalTimes(&issues_model.FindTrackedTimesOptions{IssueID: 4}) + total, err = issues_model.TotalTimesForEachUser(&issues_model.FindTrackedTimesOptions{IssueID: 4}) assert.NoError(t, err) assert.Len(t, total, 2) } diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index b33c9f972..090d23301 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1549,8 +1549,8 @@ func ViewIssue(ctx *context.Context) { } else { ctx.Data["CanUseTimetracker"] = false } - if ctx.Data["WorkingUsers"], err = issues_model.TotalTimes(&issues_model.FindTrackedTimesOptions{IssueID: issue.ID}); err != nil { - ctx.ServerError("TotalTimes", err) + if ctx.Data["WorkingUsers"], err = issues_model.TotalTimesForEachUser(&issues_model.FindTrackedTimesOptions{IssueID: issue.ID}); err != nil { + ctx.ServerError("TotalTimesForEachUser", err) return } }