feat: add optional spent on for tracking time - #38568
Draft
lunny wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
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_ondate input to the manual time entry modal and introduces new locale strings for the UI. - Persists a new
spent_on_unixvalue 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.
| 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}) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If we forget to track time, the optional Spent On field could be useful for recording the correct date.