-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Issue time estimate, meaningful time tracking #23113
Open
stuzer05
wants to merge
104
commits into
go-gitea:main
Choose a base branch
from
stuzer05:add-issue-planned-time
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
104 commits
Select commit
Hold shift + click to select a range
1363205
Commit
d11ba9f
Commit
c783692
Commit
a8778f4
Commit
d944662
Commit
7ed86ff
Commit
c248042
Commit
d75b7ac
Commit
4be8c50
Commit
5f3edad
Update services/issue/issue.go
stuzer05 f7a4c9e
Update services/issue/issue.go
stuzer05 e187364
Commit
f33b0a0
Commit
4e1aed8
Merge branch 'main' into add-issue-planned-time
stuzer05 2fc2f63
Commit
b062fc9
Commit
870bb92
Commit
d247b0f
Commit
09c05e8
Commit
0f5b609
Commit
11b9719
Commit
1b7ba41
Commit
f7427d8
Commit
1cff1a9
Commit
e155495
Commit
f463765
Commit
7a57044
Commit
79f507b
Commit
5c4dc87
Commit
0ab85af
Commit
5eea230
Commit
db3c697
Commit
775c663
Merge branch 'main' into add-issue-planned-time
stuzer05 8750870
Commit
29dd617
Commit
7be748f
Commit
b9cdc7c
Commit
8c0bf88
Merge branch 'main' into add-issue-planned-time
stuzer05 e20e23b
Commit
stuzer05 37e8e8d
Commit
stuzer05 8ef3a47
Commit
stuzer05 49a176d
Commit
stuzer05 79e18c6
Commit
stuzer05 deddce5
Commit
stuzer05 fb81260
Update models/issues/issue.go
stuzer05 bf323cf
Commit
stuzer05 57a3664
Commit
stuzer05 fd5adc5
Merge branch 'main' into add-issue-planned-time
stuzer05 879d96f
Merge branch 'main' into add-issue-planned-time
stuzer05 fc93006
Merge branch 'main' into add-issue-planned-time
stuzer05 bf4fa11
Merge branch 'main' into add-issue-planned-time
stuzer05 40e1373
Merge branch 'main' into add-issue-planned-time
stuzer05 e9afd60
Refactor helper functions
stuzer05 3924cb0
Merge branch 'go-gitea:main' into add-issue-planned-time
stuzer05 748bd67
Fix displaying issue estimation
stuzer05 015ad01
Merge branch 'main' into add-issue-planned-time
stuzer05 cef496a
Remove unused code
stuzer05 ffaa4ba
Format
stuzer05 b211b9e
Merge branch 'main' into add-issue-planned-time
silverwind 598e2d5
Merge branch 'main' into add-issue-planned-time
stuzer05 3310440
Hide time tracking
stuzer05 721069d
Merge branch 'main' into add-issue-planned-time
stuzer05 a45c1e9
Merge branch 'main' into add-issue-planned-time
stuzer05 db49783
Commit
stuzer05 e933a89
Delete serviceworker.js
stuzer05 62094d8
Merge branch 'main' into add-issue-planned-time
stuzer05 fa662ec
Merge branch 'main' into add-issue-planned-time
stuzer05 64de74d
Merge branch 'main' into add-issue-planned-time
stuzer05 349b959
Merge branch 'main' into add-issue-planned-time
stuzer05 3037d6c
Merge branch 'main' into add-issue-planned-time
stuzer05 2a9009f
Merge branch 'main' into add-issue-planned-time
stuzer05 a6fa4c3
Merge branch 'main' into add-issue-planned-time
stuzer05 a999055
Merge branch 'main' into add-issue-planned-time
stuzer05 39b8b19
Merge branch 'main' into add-issue-planned-time
stuzer05 92dc2cd
Merge branch 'main' into add-issue-planned-time
stuzer05 a737a8c
Merge branch 'main' into add-issue-planned-time
stuzer05 bb5ca4c
Merge branch 'main' into add-issue-planned-time
stuzer05 805af19
Merge branch 'main' into add-issue-planned-time
stuzer05 0c4b2df
Commit
stuzer05 c272512
Merge branch 'main' into add-issue-planned-time
stuzer05 09723c5
Merge branch 'main' into add-issue-planned-time
stuzer05 0820db0
Merge branch 'main' into add-issue-planned-time
stuzer05 93d09fa
Merge branch 'main' into add-issue-planned-time
stuzer05 1e22cc2
Merge branch 'main' into add-issue-planned-time
stuzer05 e92bedc
Commit
stuzer05 b452e13
Commit
stuzer05 b97139b
Merge branch 'main' into add-issue-planned-time
stuzer05 12553d7
Merge branch 'main' into add-issue-planned-time
stuzer05 0a8fd35
Merge branch 'main' into add-issue-planned-time
stuzer05 8c92f46
Merge branch 'main' into add-issue-planned-time
stuzer05 0c44cf7
Commit
stuzer05 a71b457
Commit
stuzer05 52d62fb
Merge branch 'main' into add-issue-planned-time
stuzer05 ff60376
Merge branch 'main' into add-issue-planned-time
stuzer05 be18b73
Merge branch 'main' into add-issue-planned-time
stuzer05 84d9dee
Merge branch 'main' into add-issue-planned-time
6543 823d67f
pass context down
6543 4ff958b
Merge branch 'main' into add-issue-planned-time
stuzer05 3499c44
Use RenderedContent
stuzer05 bf7fcba
Merge branch 'main' into add-issue-planned-time
stuzer05 392fa48
Merge branch 'main' into add-issue-planned-time
stuzer05 66b2c4a
Merge branch 'main' into add-issue-planned-time
stuzer05 10767d7
Merge branch 'main' into add-issue-planned-time
stuzer05 b24c958
Commit
stuzer05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package v1_23 //nolint | ||
|
||
import ( | ||
"xorm.io/xorm" | ||
) | ||
|
||
func AddTimeEstimateColumnToIssueTable(x *xorm.Engine) error { | ||
type Issue struct { | ||
TimeEstimate int64 `xorm:"NOT NULL DEFAULT 0"` | ||
} | ||
|
||
return x.Sync(new(Issue)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright 2022 Gitea. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package util | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
"regexp" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
var ( | ||
// Time estimate match regex | ||
rTimeEstimateOnlyHours = regexp.MustCompile(`^([\d]+)$`) | ||
rTimeEstimateWeeks = regexp.MustCompile(`([\d]+)w`) | ||
rTimeEstimateDays = regexp.MustCompile(`([\d]+)d`) | ||
rTimeEstimateHours = regexp.MustCompile(`([\d]+)h`) | ||
rTimeEstimateMinutes = regexp.MustCompile(`([\d]+)m`) | ||
) | ||
|
||
// TimeEstimateFromStr returns time estimate in seconds from formatted string | ||
func TimeEstimateFromStr(timeStr string) int64 { | ||
timeTotal := 0 | ||
|
||
// If single number entered, assume hours | ||
timeStrMatches := rTimeEstimateOnlyHours.FindStringSubmatch(timeStr) | ||
if len(timeStrMatches) > 0 { | ||
raw, _ := strconv.Atoi(timeStrMatches[1]) | ||
timeTotal += raw * (60 * 60) | ||
} else { | ||
// Find time weeks | ||
timeStrMatches = rTimeEstimateWeeks.FindStringSubmatch(timeStr) | ||
if len(timeStrMatches) > 0 { | ||
raw, _ := strconv.Atoi(timeStrMatches[1]) | ||
timeTotal += raw * (60 * 60 * 24 * 7) | ||
} | ||
|
||
// Find time days | ||
timeStrMatches = rTimeEstimateDays.FindStringSubmatch(timeStr) | ||
if len(timeStrMatches) > 0 { | ||
raw, _ := strconv.Atoi(timeStrMatches[1]) | ||
timeTotal += raw * (60 * 60 * 24) | ||
} | ||
|
||
// Find time hours | ||
timeStrMatches = rTimeEstimateHours.FindStringSubmatch(timeStr) | ||
if len(timeStrMatches) > 0 { | ||
raw, _ := strconv.Atoi(timeStrMatches[1]) | ||
timeTotal += raw * (60 * 60) | ||
} | ||
|
||
// Find time minutes | ||
timeStrMatches = rTimeEstimateMinutes.FindStringSubmatch(timeStr) | ||
if len(timeStrMatches) > 0 { | ||
raw, _ := strconv.Atoi(timeStrMatches[1]) | ||
timeTotal += raw * (60) | ||
} | ||
} | ||
|
||
return int64(timeTotal) | ||
} | ||
|
||
// TimeEstimateStr returns formatted time estimate string from seconds (e.g. "2w 4d 12h 5m") | ||
func TimeEstimateToStr(amount int64) string { | ||
var timeParts []string | ||
|
||
timeSeconds := float64(amount) | ||
|
||
// Format weeks | ||
weeks := math.Floor(timeSeconds / (60 * 60 * 24 * 7)) | ||
if weeks > 0 { | ||
timeParts = append(timeParts, fmt.Sprintf("%dw", int64(weeks))) | ||
} | ||
timeSeconds -= weeks * (60 * 60 * 24 * 7) | ||
|
||
// Format days | ||
days := math.Floor(timeSeconds / (60 * 60 * 24)) | ||
if days > 0 { | ||
timeParts = append(timeParts, fmt.Sprintf("%dd", int64(days))) | ||
} | ||
timeSeconds -= days * (60 * 60 * 24) | ||
|
||
// Format hours | ||
hours := math.Floor(timeSeconds / (60 * 60)) | ||
if hours > 0 { | ||
timeParts = append(timeParts, fmt.Sprintf("%dh", int64(hours))) | ||
} | ||
timeSeconds -= hours * (60 * 60) | ||
|
||
// Format minutes | ||
minutes := math.Floor(timeSeconds / (60)) | ||
if minutes > 0 { | ||
timeParts = append(timeParts, fmt.Sprintf("%dm", int64(minutes))) | ||
} | ||
|
||
return strings.Join(timeParts, " ") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
adding tests for this function would be awesome!
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.
Will work on it