2021-03-23 03:09:04 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
class TimelogType < BaseObject
|
|
|
|
graphql_name 'Timelog'
|
|
|
|
|
2021-06-01 21:10:06 +00:00
|
|
|
authorize :read_issue
|
2021-03-23 03:09:04 +00:00
|
|
|
|
|
|
|
field :spent_at,
|
|
|
|
Types::TimeType,
|
|
|
|
null: true,
|
|
|
|
description: 'Timestamp of when the time tracked was spent at.'
|
|
|
|
|
|
|
|
field :time_spent,
|
2021-07-23 12:09:05 +00:00
|
|
|
GraphQL::Types::Int,
|
2021-03-23 03:09:04 +00:00
|
|
|
null: false,
|
|
|
|
description: 'The time spent displayed in seconds.'
|
|
|
|
|
|
|
|
field :user,
|
|
|
|
Types::UserType,
|
|
|
|
null: false,
|
|
|
|
description: 'The user that logged the time.'
|
|
|
|
|
|
|
|
field :issue,
|
|
|
|
Types::IssueType,
|
|
|
|
null: true,
|
|
|
|
description: 'The issue that logged time was added to.'
|
|
|
|
|
2021-05-06 12:10:38 +00:00
|
|
|
field :merge_request,
|
|
|
|
Types::MergeRequestType,
|
|
|
|
null: true,
|
|
|
|
description: 'The merge request that logged time was added to.'
|
|
|
|
|
2021-03-23 03:09:04 +00:00
|
|
|
field :note,
|
|
|
|
Types::Notes::NoteType,
|
|
|
|
null: true,
|
|
|
|
description: 'The note where the quick action to add the logged time was executed.'
|
|
|
|
|
2021-07-29 15:09:48 +00:00
|
|
|
field :summary, GraphQL::Types::String,
|
|
|
|
null: true,
|
|
|
|
description: 'The summary of how the time was spent.'
|
|
|
|
|
2021-03-23 03:09:04 +00:00
|
|
|
def user
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find
|
|
|
|
end
|
|
|
|
|
|
|
|
def issue
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(Issue, object.issue_id).find
|
|
|
|
end
|
2021-05-14 09:10:24 +00:00
|
|
|
|
|
|
|
def spent_at
|
|
|
|
object.spent_at || object.created_at
|
|
|
|
end
|
2021-03-23 03:09:04 +00:00
|
|
|
end
|
|
|
|
end
|