Commit e471d716 authored by Eugenia Grieff's avatar Eugenia Grieff

Deprecate date field in TimelogType

- Add field spent_at
- Add new field to specs
- Update GraphQL schema and docs

- Add changelog file
parent 92d4d9bf
...@@ -8053,15 +8053,20 @@ scalar Time ...@@ -8053,15 +8053,20 @@ scalar Time
type Timelog { type Timelog {
""" """
The date when the time tracked was spent at Timestamp of when the time tracked was spent at. Deprecated in 12.10: Use `spentAt`
""" """
date: Time! date: Time! @deprecated(reason: "Use `spentAt`. Deprecated in 12.10")
""" """
The issue that logged time was added to The issue that logged time was added to
""" """
issue: Issue issue: Issue
"""
Timestamp of when the time tracked was spent at
"""
spentAt: Time
""" """
The time spent displayed in seconds The time spent displayed in seconds
""" """
......
...@@ -24308,7 +24308,7 @@ ...@@ -24308,7 +24308,7 @@
"fields": [ "fields": [
{ {
"name": "date", "name": "date",
"description": "The date when the time tracked was spent at", "description": "Timestamp of when the time tracked was spent at. Deprecated in 12.10: Use `spentAt`",
"args": [ "args": [
], ],
...@@ -24321,8 +24321,8 @@ ...@@ -24321,8 +24321,8 @@
"ofType": null "ofType": null
} }
}, },
"isDeprecated": false, "isDeprecated": true,
"deprecationReason": null "deprecationReason": "Use `spentAt`. Deprecated in 12.10"
}, },
{ {
"name": "issue", "name": "issue",
...@@ -24338,6 +24338,20 @@ ...@@ -24338,6 +24338,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "spentAt",
"description": "Timestamp of when the time tracked was spent at",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "timeSpent", "name": "timeSpent",
"description": "The time spent displayed in seconds", "description": "The time spent displayed in seconds",
......
...@@ -1272,8 +1272,9 @@ Completion status of tasks ...@@ -1272,8 +1272,9 @@ Completion status of tasks
| Name | Type | Description | | Name | Type | Description |
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `date` | Time! | The date when the time tracked was spent at | | `date` **{warning-solid}** | Time! | **Deprecated:** Use `spentAt`. Deprecated in 12.10 |
| `issue` | Issue | The issue that logged time was added to | | `issue` | Issue | The issue that logged time was added to |
| `spentAt` | Time | Timestamp of when the time tracked was spent at |
| `timeSpent` | Int! | The time spent displayed in seconds | | `timeSpent` | Int! | The time spent displayed in seconds |
| `user` | User! | The user that logged the time | | `user` | User! | The user that logged the time |
......
...@@ -10,7 +10,13 @@ module Types ...@@ -10,7 +10,13 @@ module Types
Types::TimeType, Types::TimeType,
null: false, null: false,
method: :spent_at, method: :spent_at,
description: 'The date when the time tracked was spent at' deprecated: { reason: 'Use `spentAt`', milestone: '12.10' },
description: 'Timestamp of when the time tracked was spent at'
field :spent_at,
Types::TimeType,
null: true,
description: 'Timestamp of when the time tracked was spent at'
field :time_spent, field :time_spent,
GraphQL::INT_TYPE, GraphQL::INT_TYPE,
......
---
title: Add spentAt field to TimelogType and deprecate date field
merge_request: 29024
author:
type: added
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe GitlabSchema.types['Timelog'] do describe GitlabSchema.types['Timelog'] do
let(:fields) { %i[date time_spent user issue] } let(:fields) { %i[date spent_at time_spent user issue] }
it { expect(described_class.graphql_name).to eq('Timelog') } it { expect(described_class.graphql_name).to eq('Timelog') }
it { expect(described_class).to have_graphql_fields(fields) } it { expect(described_class).to have_graphql_fields(fields) }
......
...@@ -19,6 +19,7 @@ describe 'Timelogs through GroupQuery' do ...@@ -19,6 +19,7 @@ describe 'Timelogs through GroupQuery' do
timelog_nodes = <<~NODE timelog_nodes = <<~NODE
nodes { nodes {
date date
spentAt
timeSpent timeSpent
user { user {
username username
...@@ -65,14 +66,16 @@ describe 'Timelogs through GroupQuery' do ...@@ -65,14 +66,16 @@ describe 'Timelogs through GroupQuery' do
it 'contains correct data' do it 'contains correct data' do
username = timelog_array.map {|data| data['user']['username'] } username = timelog_array.map {|data| data['user']['username'] }
date = timelog_array.map { |data| data['date'].to_date.to_s } date = timelog_array.map { |data| data['date'].to_time }
spent_at = timelog_array.map { |data| data['spentAt'].to_time }
time_spent = timelog_array.map { |data| data['timeSpent'] } time_spent = timelog_array.map { |data| data['timeSpent'] }
issue_title = timelog_array.map {|data| data['issue']['title'] } issue_title = timelog_array.map {|data| data['issue']['title'] }
milestone_title = timelog_array.map {|data| data['issue']['milestone']['title'] } milestone_title = timelog_array.map {|data| data['issue']['milestone']['title'] }
epic_title = timelog_array.map {|data| data['issue']['epic']['title'] } epic_title = timelog_array.map {|data| data['issue']['epic']['title'] }
expect(username).to eq([user.username]) expect(username).to eq([user.username])
expect(date).to eq([timelog1.spent_at.to_date.to_s]) expect(date.first).to be_like_time(timelog1.spent_at)
expect(spent_at.first).to be_like_time(timelog1.spent_at)
expect(time_spent).to eq([timelog1.time_spent]) expect(time_spent).to eq([timelog1.time_spent])
expect(issue_title).to eq([issue.title]) expect(issue_title).to eq([issue.title])
expect(milestone_title).to eq([milestone.title]) expect(milestone_title).to eq([milestone.title])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment