This commit is contained in:
stuzer05 2023-02-28 16:07:09 +02:00
parent fb8126035a
commit bf323cf26c
No known key found for this signature in database
GPG Key ID: A6ABAAA9268F9F4F

View File

@ -2536,12 +2536,12 @@ func (issue *Issue) HasOriginalAuthor() bool {
} }
var ( var (
// Time match regex // Time estimate match regex
rOnlyHours = regexp.MustCompile(`^([\d]+)$`) rTimeEstimateOnlyHours = regexp.MustCompile(`^([\d]+)$`)
rWeeks = regexp.MustCompile(`([\d]+)w`) rTimeEstimateWeeks = regexp.MustCompile(`([\d]+)w`)
rDays = regexp.MustCompile(`([\d]+)d`) rTimeEstimateDays = regexp.MustCompile(`([\d]+)d`)
rHours = regexp.MustCompile(`([\d]+)h`) rTimeEstimateHours = regexp.MustCompile(`([\d]+)h`)
rMinutes = regexp.MustCompile(`([\d]+)m`) rTimeEstimateMinutes = regexp.MustCompile(`([\d]+)m`)
) )
// TimeEstimateFromStr returns time estimate in seconds from formatted string // TimeEstimateFromStr returns time estimate in seconds from formatted string
@ -2549,34 +2549,34 @@ func (issue *Issue) TimeEstimateFromStr(timeStr string) int64 {
timeTotal := 0 timeTotal := 0
// If single number entered, assume hours // If single number entered, assume hours
timeStrMatches := rOnlyHours.FindStringSubmatch(timeStr) timeStrMatches := rTimeEstimateOnlyHours.FindStringSubmatch(timeStr)
if len(timeStrMatches) > 0 { if len(timeStrMatches) > 0 {
raw, _ := strconv.Atoi(timeStrMatches[1]) raw, _ := strconv.Atoi(timeStrMatches[1])
timeTotal += raw * (60 * 60) timeTotal += raw * (60 * 60)
} else { } else {
// Find time weeks // Find time weeks
timeStrMatches = rWeeks.FindStringSubmatch(timeStr) timeStrMatches = rTimeEstimateWeeks.FindStringSubmatch(timeStr)
if len(timeStrMatches) > 0 { if len(timeStrMatches) > 0 {
raw, _ := strconv.Atoi(timeStrMatches[1]) raw, _ := strconv.Atoi(timeStrMatches[1])
timeTotal += raw * (60 * 60 * 24 * 7) timeTotal += raw * (60 * 60 * 24 * 7)
} }
// Find time days // Find time days
timeStrMatches = rDays.FindStringSubmatch(timeStr) timeStrMatches = rTimeEstimateDays.FindStringSubmatch(timeStr)
if len(timeStrMatches) > 0 { if len(timeStrMatches) > 0 {
raw, _ := strconv.Atoi(timeStrMatches[1]) raw, _ := strconv.Atoi(timeStrMatches[1])
timeTotal += raw * (60 * 60 * 24) timeTotal += raw * (60 * 60 * 24)
} }
// Find time hours // Find time hours
timeStrMatches = rHours.FindStringSubmatch(timeStr) timeStrMatches = rTimeEstimateHours.FindStringSubmatch(timeStr)
if len(timeStrMatches) > 0 { if len(timeStrMatches) > 0 {
raw, _ := strconv.Atoi(timeStrMatches[1]) raw, _ := strconv.Atoi(timeStrMatches[1])
timeTotal += raw * (60 * 60) timeTotal += raw * (60 * 60)
} }
// Find time minutes // Find time minutes
timeStrMatches = rMinutes.FindStringSubmatch(timeStr) timeStrMatches = rTimeEstimateMinutes.FindStringSubmatch(timeStr)
if len(timeStrMatches) > 0 { if len(timeStrMatches) > 0 {
raw, _ := strconv.Atoi(timeStrMatches[1]) raw, _ := strconv.Atoi(timeStrMatches[1])
timeTotal += raw * (60) timeTotal += raw * (60)