Skip to content

feat: add optional spent on for tracking time - #38568

Draft
lunny wants to merge 1 commit into
go-gitea:mainfrom
lunny:lunny/track_time_spent_on
Draft

feat: add optional spent on for tracking time#38568
lunny wants to merge 1 commit into
go-gitea:mainfrom
lunny:lunny/track_time_spent_on

Conversation

@lunny

@lunny lunny commented Jul 22, 2026

Copy link
Copy Markdown
Member

If we forget to track time, the optional Spent On field could be useful for recording the correct date.

image

Copilot AI review requested due to automatic review settings July 22, 2026 03:55
@lunny lunny added the type/enhancement An improvement of existing functionality label Jul 22, 2026
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 22, 2026
@lunny lunny added this to the 28.0.0 milestone Jul 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional “Spent on” date when manually adding tracked time to issues, so users can record the correct work date even if time tracking was entered later.

Changes:

  • Adds a spent_on date input to the manual time entry modal and introduces new locale strings for the UI.
  • Persists a new spent_on_unix value on tracked time entries (with a DB migration and fixture updates) and updates reporting/filter queries to use it.
  • Extends integration/unit tests to cover the new spent-on behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/integration/issue_timetrack_test.go Adds an integration test covering spent_on submission and persistence.
templates/repo/issue/sidebar/stopwatch_timetracker.tmpl Adds a date field to the manual add-time modal UI.
services/forms/repo_form.go Extends the manual time form to accept spent_on.
services/convert/issue.go Changes API conversion to populate created from spent_on (flagged in review).
routers/web/repo/issue_timetrack.go Parses optional spent_on and passes it to tracked time creation.
routers/api/v1/repo/issue_tracked_time.go Treats API created input as “spent on” when adding time (flagged in review).
options/locale/locale_en-US.json Adds UI strings for duration/spent-on and invalid date error.
models/organization/org_worktime.go Switches org worktime aggregation filters to spent_on_unix.
models/issues/tracked_time.go Introduces SpentOnUnix, defaults/fallback in AfterLoad, and writes spent_on_unix on insert; filters now use spent_on_unix.
models/issues/tracked_time_test.go Updates unit test to assert SpentOnUnix is stored.
models/fixtures/tracked_time.yml Adds spent_on_unix fixture data.
modelmigration/v1_28/v343.go Adds migration to create/populate spent_on_unix.
modelmigration/migrations.go Registers migration 343.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/convert/issue.go
UserID: t.UserID,
Time: t.Time,
Created: t.Created,
Created: t.SpentOn,
Comment on lines 231 to +235
if !form.Created.IsZero() {
created = form.Created
spentOn = form.Created
}

trackedTime, err := issues_model.AddTime(ctx, user, issue, form.Time, created)
trackedTime, err := issues_model.AddTime(ctx, user, issue, form.Time, spentOn)
Comment on lines 117 to +121
if opts.CreatedAfterUnix != 0 {
cond = cond.And(builder.Gte{"tracked_time.created_unix": opts.CreatedAfterUnix})
cond = cond.And(builder.Gte{"tracked_time.spent_on_unix": opts.CreatedAfterUnix})
}
if opts.CreatedBeforeUnix != 0 {
cond = cond.And(builder.Lte{"tracked_time.created_unix": opts.CreatedBeforeUnix})
cond = cond.And(builder.Lte{"tracked_time.spent_on_unix": opts.CreatedBeforeUnix})
@silverwind silverwind changed the title Add optional spent on for tracking time feat: add optional spent on for tracking time Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants