Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

Defining a custom "hours per day" other than Gitlab 8 hours produces invalid TIME RECORDS "time" and ISSUES "spent" from Gitlab #83

@ghost

Description

That's pretty simple to reproduce.

  1. Create a new issue
  2. Using a quick-action in a comment, enter:

/spend 1d

  1. With gtt output the full data for the created issue, specifying anything else than 8 hours per day. For example,

gtt report [group/project] iid --hours_per_day=7 --time_format [%hours_overall]

The TIME STATS section outputs a total spent and a spent of 8, which is fine.

The ISSUES and TIME RECORDS sections respectively show a spent and a time of 7. Which is NOT consistent with the TIME STATS and with Gitlab.

I tracked down the code, from the regex that extracts added [x] time spent at [y] -

let timeString = match ? match[1] : (subMatch ? `-${subMatch[1]}` : `-${Time.toHumanReadable(timeSpent, this.config.get('hoursPerDay'))}`);

It calls the time constructor which in turn calls the time.parse function passing the this._hoursPerDay as hoursPerDay argument from the config instead of specifying the Gitlab default 8 hours.

this.seconds = time.parse(timeString, this._hoursPerDay, this._daysPerWeek, this._weeksPerMonth);

Gitlab does NOT support anything else than 1d = 8h and saves the issue time tracking stats in seconds. This means that querying the issue in Gitlab actually tells to everyone that there are a total of 28800 seconds spent on the issue - see total_time_spent https://docs.gitlab.com/ee/api/issues.html#get-time-tracking-stats - not 25200 seconds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions