Commit b8208723 authored by Lee Tickett's avatar Lee Tickett

Add timelog summary to time tracking report

Changelog: added
parent 0902a6f8
......@@ -7,4 +7,5 @@ fragment TimelogFragment on Timelog {
note {
body
}
summary
}
......@@ -62,8 +62,8 @@ export default {
formatDate(date) {
return formatDate(date, TIME_DATE_FORMAT);
},
getNote(note) {
return note?.body;
getSummary(summary, note) {
return summary ?? note?.body;
},
getTotalTimeSpent() {
const seconds = this.report.reduce((acc, item) => acc + item.timeSpent, 0);
......@@ -81,7 +81,7 @@ export default {
{ key: 'spentAt', label: __('Spent At'), sortable: true },
{ key: 'user', label: __('User'), sortable: true },
{ key: 'timeSpent', label: __('Time Spent'), sortable: true },
{ key: 'note', label: __('Note'), sortable: true },
{ key: 'summary', label: __('Summary / Note'), sortable: true },
],
};
</script>
......@@ -107,8 +107,8 @@ export default {
<div>{{ getTotalTimeSpent() }}</div>
</template>
<template #cell(note)="{ item: { note } }">
<div>{{ getNote(note) }}</div>
<template #cell(summary)="{ item: { summary, note } }">
<div>{{ getSummary(summary, note) }}</div>
</template>
<template #foot(note)>&nbsp;</template>
</gl-table>
......
......@@ -36,6 +36,10 @@ module Types
null: true,
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
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find
end
......
......@@ -13381,6 +13381,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="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="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="timeloguser"></a>`user` | [`UserCore!`](#usercore) | The user that logged the time. |
......
......@@ -31788,6 +31788,9 @@ msgstr ""
msgid "Summary"
msgstr ""
msgid "Summary / Note"
msgstr ""
msgid "Sunday"
msgstr ""
......
......@@ -16,9 +16,10 @@ export const getIssueTimelogsQueryResponse = {
},
spentAt: '2020-05-01T00:00:00Z',
note: {
body: 'I paired with @root on this last week.',
body: 'A note',
__typename: 'Note',
},
summary: 'A summary',
},
{
__typename: 'Timelog',
......@@ -29,6 +30,7 @@ export const getIssueTimelogsQueryResponse = {
},
spentAt: '2021-05-07T13:19:01Z',
note: null,
summary: 'A summary',
},
{
__typename: 'Timelog',
......@@ -39,9 +41,10 @@ export const getIssueTimelogsQueryResponse = {
},
spentAt: '2021-05-01T00:00:00Z',
note: {
body: 'I did some work on this last week.',
body: 'A note',
__typename: 'Note',
},
summary: null,
},
],
__typename: 'TimelogConnection',
......@@ -70,6 +73,7 @@ export const getMrTimelogsQueryResponse = {
body: 'Thirty minutes!',
__typename: 'Note',
},
summary: null,
},
{
__typename: 'Timelog',
......@@ -80,6 +84,7 @@ export const getMrTimelogsQueryResponse = {
},
spentAt: '2021-05-07T14:44:39Z',
note: null,
summary: null,
},
{
__typename: 'Timelog',
......@@ -93,6 +98,7 @@ export const getMrTimelogsQueryResponse = {
body: 'A note with some time',
__typename: 'Note',
},
summary: null,
},
],
__typename: 'TimelogConnection',
......
......@@ -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: /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 @@
require 'spec_helper'
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).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