Commit 4532823f authored by Lee Tickett's avatar Lee Tickett Committed by Heinrich Lee Yu

Add note to graphql timelog_type

parent b050cbf8
......@@ -556,6 +556,8 @@ class Note < ApplicationRecord
end
def system_note_with_references_visible_for?(user)
return true unless system?
(!system_note_with_references? || all_referenced_mentionables_allowed?(user)) && system_note_viewable_by?(user)
end
......
......@@ -7,6 +7,7 @@ class Timelog < ApplicationRecord
belongs_to :issue, touch: true
belongs_to :merge_request, touch: true
belongs_to :user
belongs_to :note
scope :for_issues_in_group, -> (group) do
joins(:issue).where(
......
---
title: Add note to graphql timelog_type
merge_request: 37748
author: Lee Tickett
type: added
......@@ -16052,6 +16052,11 @@ type Timelog {
"""
issue: Issue
"""
The note where the quick action to add the logged time was executed
"""
note: Note
"""
Timestamp of when the time tracked was spent at
"""
......
......@@ -47222,6 +47222,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "note",
"description": "The note where the quick action to add the logged time was executed",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "Note",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "spentAt",
"description": "Timestamp of when the time tracked was spent at",
......@@ -2351,6 +2351,7 @@ Represents a requirement test report.
| --- | ---- | ---------- |
| `date` **{warning-solid}** | Time! | **Deprecated:** Use `spentAt`. Deprecated in 12.10 |
| `issue` | Issue | The issue that logged time was added to |
| `note` | Note | The note where the quick action to add the logged time was executed |
| `spentAt` | Time | Timestamp of when the time tracked was spent at |
| `timeSpent` | Int! | The time spent displayed in seconds |
| `user` | User! | The user that logged the time |
......
......@@ -27,6 +27,7 @@ module EE
field :timelogs, ::Types::TimelogType.connection_type, null: false,
description: 'Time logged in issues by group members',
extras: [:lookahead],
complexity: 5,
resolver: ::Resolvers::TimelogResolver
......
......@@ -2,6 +2,8 @@
module Resolvers
class TimelogResolver < BaseResolver
include LooksAhead
argument :start_date, Types::TimeType,
required: false,
description: 'List time logs within a date range where the logged date is equal to or after startDate'
......@@ -18,7 +20,7 @@ module Resolvers
required: false,
description: 'List time-logs within a time range where the logged time is equal to or before endTime'
def resolve(**args)
def resolve_with_lookahead(**args)
return Timelog.none unless timelogs_available_for_user?
validate_params_presence!(args)
......@@ -30,8 +32,14 @@ module Resolvers
private
def preloads
{
note: [:note]
}
end
def find_timelogs(args)
group.timelogs(args[:start_time], args[:end_time])
apply_lookahead(group.timelogs(args[:start_time], args[:end_time]))
end
def timelogs_available_for_user?
......
......@@ -34,5 +34,10 @@ module Types
null: true,
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Issue, obj.issue_id).find },
description: 'The issue that logged time was added to'
field :note,
Types::Notes::NoteType,
null: true,
description: 'The note where the quick action to add the logged time was executed'
end
end
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe GitlabSchema.types['Timelog'] do
let(:fields) { %i[date spent_at time_spent user issue] }
let(:fields) { %i[date spent_at time_spent user issue note] }
it { expect(described_class.graphql_name).to eq('Timelog') }
it { expect(described_class).to have_graphql_fields(fields) }
......@@ -24,4 +24,12 @@ RSpec.describe GitlabSchema.types['Timelog'] do
is_expected.to have_graphql_type(Types::IssueType)
end
end
describe 'note field' do
subject { described_class.fields['note'] }
it 'returns note' do
is_expected.to have_graphql_type(Types::Notes::NoteType)
end
end
end
......@@ -539,6 +539,7 @@ timelogs:
- issue
- merge_request
- user
- note
push_event_payload:
- event
issue_assignees:
......
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