Skip to content

Commit

Permalink
rename TotalTimes() to TotalTimesForEachUser() (#27261)
Browse files Browse the repository at this point in the history
make function name more descriptive as it would otherwise imply it could
be used for e.g. #26672 too ...

---
*Sponsored by Kithara Software GmbH*
  • Loading branch information
6543 authored Sep 29, 2023
1 parent cf0df02 commit 2a2b0cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions models/issues/tracked_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions models/issues/tracked_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,18 @@ 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 {
assert.EqualValues(t, 1, user.ID)
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 {
Expand All @@ -103,15 +103,15 @@ 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 {
assert.EqualValues(t, 2, user.ID)
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)
}
4 changes: 2 additions & 2 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 2a2b0cb

Please sign in to comment.