Commit 769ec6da authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch '330839-add-summary-to-time-tracking-report' into 'master'

Add timelog summary to time tracking report

See merge request gitlab-org/gitlab!67006
parents 3deb11c1 b8208723
...@@ -7,4 +7,5 @@ fragment TimelogFragment on Timelog { ...@@ -7,4 +7,5 @@ fragment TimelogFragment on Timelog {
note { note {
body body
} }
summary
} }
...@@ -62,8 +62,8 @@ export default { ...@@ -62,8 +62,8 @@ export default {
formatDate(date) { formatDate(date) {
return formatDate(date, TIME_DATE_FORMAT); return formatDate(date, TIME_DATE_FORMAT);
}, },
getNote(note) { getSummary(summary, note) {
return note?.body; return summary ?? note?.body;
}, },
getTotalTimeSpent() { getTotalTimeSpent() {
const seconds = this.report.reduce((acc, item) => acc + item.timeSpent, 0); const seconds = this.report.reduce((acc, item) => acc + item.timeSpent, 0);
...@@ -81,7 +81,7 @@ export default { ...@@ -81,7 +81,7 @@ export default {
{ key: 'spentAt', label: __('Spent At'), sortable: true }, { key: 'spentAt', label: __('Spent At'), sortable: true },
{ key: 'user', label: __('User'), sortable: true }, { key: 'user', label: __('User'), sortable: true },
{ key: 'timeSpent', label: __('Time Spent'), sortable: true }, { key: 'timeSpent', label: __('Time Spent'), sortable: true },
{ key: 'note', label: __('Note'), sortable: true }, { key: 'summary', label: __('Summary / Note'), sortable: true },
], ],
}; };
</script> </script>
...@@ -107,8 +107,8 @@ export default { ...@@ -107,8 +107,8 @@ export default {
<div>{{ getTotalTimeSpent() }}</div> <div>{{ getTotalTimeSpent() }}</div>
</template> </template>
<template #cell(note)="{ item: { note } }"> <template #cell(summary)="{ item: { summary, note } }">
<div>{{ getNote(note) }}</div> <div>{{ getSummary(summary, note) }}</div>
</template> </template>
<template #foot(note)>&nbsp;</template> <template #foot(note)>&nbsp;</template>
</gl-table> </gl-table>
......
...@@ -36,6 +36,10 @@ module Types ...@@ -36,6 +36,10 @@ module Types
null: true, null: true,
description: 'The note where the quick action to add the logged time was executed.' description: 'The note where the quick action to add the logged time was executed.'
field :summary, GraphQL::Types::String,
null: true,
description: 'The summary of how the time was spent.'
def user def user
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find
end end
......
...@@ -13482,6 +13482,7 @@ Represents a historically accurate report about the timebox. ...@@ -13482,6 +13482,7 @@ Represents a historically accurate report about the timebox.
| <a id="timelogmergerequest"></a>`mergeRequest` | [`MergeRequest`](#mergerequest) | The merge request that logged time was added to. | | <a id="timelogmergerequest"></a>`mergeRequest` | [`MergeRequest`](#mergerequest) | The merge request that logged time was added to. |
| <a id="timelognote"></a>`note` | [`Note`](#note) | The note where the quick action to add the logged time was executed. | | <a id="timelognote"></a>`note` | [`Note`](#note) | The note where the quick action to add the logged time was executed. |
| <a id="timelogspentat"></a>`spentAt` | [`Time`](#time) | Timestamp of when the time tracked was spent at. | | <a id="timelogspentat"></a>`spentAt` | [`Time`](#time) | Timestamp of when the time tracked was spent at. |
| <a id="timelogsummary"></a>`summary` | [`String`](#string) | The summary of how the time was spent. |
| <a id="timelogtimespent"></a>`timeSpent` | [`Int!`](#int) | The time spent displayed in seconds. | | <a id="timelogtimespent"></a>`timeSpent` | [`Int!`](#int) | The time spent displayed in seconds. |
| <a id="timeloguser"></a>`user` | [`UserCore!`](#usercore) | The user that logged the time. | | <a id="timeloguser"></a>`user` | [`UserCore!`](#usercore) | The user that logged the time. |
......
...@@ -31828,6 +31828,9 @@ msgstr "" ...@@ -31828,6 +31828,9 @@ msgstr ""
msgid "Summary" msgid "Summary"
msgstr "" msgstr ""
msgid "Summary / Note"
msgstr ""
msgid "Sunday" msgid "Sunday"
msgstr "" msgstr ""
......
...@@ -16,9 +16,10 @@ export const getIssueTimelogsQueryResponse = { ...@@ -16,9 +16,10 @@ export const getIssueTimelogsQueryResponse = {
}, },
spentAt: '2020-05-01T00:00:00Z', spentAt: '2020-05-01T00:00:00Z',
note: { note: {
body: 'I paired with @root on this last week.', body: 'A note',
__typename: 'Note', __typename: 'Note',
}, },
summary: 'A summary',
}, },
{ {
__typename: 'Timelog', __typename: 'Timelog',
...@@ -29,6 +30,7 @@ export const getIssueTimelogsQueryResponse = { ...@@ -29,6 +30,7 @@ export const getIssueTimelogsQueryResponse = {
}, },
spentAt: '2021-05-07T13:19:01Z', spentAt: '2021-05-07T13:19:01Z',
note: null, note: null,
summary: 'A summary',
}, },
{ {
__typename: 'Timelog', __typename: 'Timelog',
...@@ -39,9 +41,10 @@ export const getIssueTimelogsQueryResponse = { ...@@ -39,9 +41,10 @@ export const getIssueTimelogsQueryResponse = {
}, },
spentAt: '2021-05-01T00:00:00Z', spentAt: '2021-05-01T00:00:00Z',
note: { note: {
body: 'I did some work on this last week.', body: 'A note',
__typename: 'Note', __typename: 'Note',
}, },
summary: null,
}, },
], ],
__typename: 'TimelogConnection', __typename: 'TimelogConnection',
...@@ -70,6 +73,7 @@ export const getMrTimelogsQueryResponse = { ...@@ -70,6 +73,7 @@ export const getMrTimelogsQueryResponse = {
body: 'Thirty minutes!', body: 'Thirty minutes!',
__typename: 'Note', __typename: 'Note',
}, },
summary: null,
}, },
{ {
__typename: 'Timelog', __typename: 'Timelog',
...@@ -80,6 +84,7 @@ export const getMrTimelogsQueryResponse = { ...@@ -80,6 +84,7 @@ export const getMrTimelogsQueryResponse = {
}, },
spentAt: '2021-05-07T14:44:39Z', spentAt: '2021-05-07T14:44:39Z',
note: null, note: null,
summary: null,
}, },
{ {
__typename: 'Timelog', __typename: 'Timelog',
...@@ -93,6 +98,7 @@ export const getMrTimelogsQueryResponse = { ...@@ -93,6 +98,7 @@ export const getMrTimelogsQueryResponse = {
body: 'A note with some time', body: 'A note with some time',
__typename: 'Note', __typename: 'Note',
}, },
summary: null,
}, },
], ],
__typename: 'TimelogConnection', __typename: 'TimelogConnection',
......
...@@ -74,6 +74,8 @@ describe('Issuable Time Tracking Report', () => { ...@@ -74,6 +74,8 @@ describe('Issuable Time Tracking Report', () => {
expect(getAllByRole(wrapper.element, 'row', { name: /John Doe18/i })).toHaveLength(1); expect(getAllByRole(wrapper.element, 'row', { name: /John Doe18/i })).toHaveLength(1);
expect(getAllByRole(wrapper.element, 'row', { name: /Administrator/i })).toHaveLength(2); expect(getAllByRole(wrapper.element, 'row', { name: /Administrator/i })).toHaveLength(2);
expect(getAllByRole(wrapper.element, 'row', { name: /A note/i })).toHaveLength(1);
expect(getAllByRole(wrapper.element, 'row', { name: /A summary/i })).toHaveLength(2);
}); });
}); });
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe GitlabSchema.types['Timelog'] do RSpec.describe GitlabSchema.types['Timelog'] do
let(:fields) { %i[spent_at time_spent user issue merge_request note] } let(:fields) { %i[spent_at time_spent user issue merge_request note summary] }
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) }
......
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