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