Set spent time when using timelogs API
What does this MR do and why?
At the moment we don't set the spent_at
time when creating
timelogs via the API. This is causing issues when filtering.
This MR addresses this initially by setting it to the current time.
Moving forward, we can look to support passing a time in.
Migrations
lee@cc-gdk-2:~/gitlab-development-kit/gitlab$ bundle exec rake db:migrate:down VERSION=20211213130324 RAILS_ENV=development
== 20211213130324 UpdateTimelogsSpentAtDefault: reverting =====================
-- change_column_default(:timelogs, :spent_at, {:from=>#<Proc:0x00005563b1af2570 /home/lee/gitlab-development-kit/gitlab/db/migrate/20211213130324_update_timelogs_spent_at_default.rb:5 (lambda)>, :to=>nil})
-> 0.0042s
== 20211213130324 UpdateTimelogsSpentAtDefault: reverted (0.0059s) ============
lee@cc-gdk-2:~/gitlab-development-kit/gitlab$ bundle exec rake db:migrate:up VERSION=20211213130324 RAILS_ENV=development
== 20211213130324 UpdateTimelogsSpentAtDefault: migrating =====================
-- change_column_default(:timelogs, :spent_at, {:from=>nil, :to=>#<Proc:0x000055d799913b30 /home/lee/gitlab-development-kit/gitlab/db/migrate/20211213130324_update_timelogs_spent_at_default.rb:5 (lambda)>})
-> 0.0041s
== 20211213130324 UpdateTimelogsSpentAtDefault: migrated (0.0042s) ============
Validation steps
- Create a personal access token
- Add a timelog using the API
http://gdk.test:3000/api/v4/projects/6/issues/35/add_spent_time { "duration": 5 }
- Check the timelog record in the database has a valid
spent_at
value
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #347473 (closed)
Edited by Lee Tickett