2021-03-23 03:09:04 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
class TimelogType < BaseObject
|
|
|
|
graphql_name 'Timelog'
|
|
|
|
|
2022-08-30 15:10:02 +00:00
|
|
|
authorize :read_issuable
|
2021-03-23 03:09:04 +00:00
|
|
|
|
2022-05-11 15:07:26 +00:00
|
|
|
expose_permissions Types::PermissionTypes::Timelog
|
|
|
|
|
2022-04-22 15:09:52 +00:00
|
|
|
field :id,
|
|
|
|
GraphQL::Types::ID,
|
|
|
|
null: false,
|
|
|
|
description: 'Internal ID of the timelog.'
|
|
|
|
|
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,
|
2021-08-31 15:10:29 +00:00
|
|
|
description: 'Time spent displayed in seconds.'
|
2021-03-23 03:09:04 +00:00
|
|
|
|
|
|
|
field :user,
|
|
|
|
Types::UserType,
|
|
|
|
null: false,
|
2021-08-31 15:10:29 +00:00
|
|
|
description: 'User that logged the time.'
|
2021-03-23 03:09:04 +00:00
|
|
|
|
|
|
|
field :issue,
|
|
|
|
Types::IssueType,
|
|
|
|
null: true,
|
2021-08-31 15:10:29 +00:00
|
|
|
description: 'Issue that logged time was added to.'
|
2021-03-23 03:09:04 +00:00
|
|
|
|
2021-05-06 12:10:38 +00:00
|
|
|
field :merge_request,
|
|
|
|
Types::MergeRequestType,
|
|
|
|
null: true,
|
2021-08-31 15:10:29 +00:00
|
|
|
description: 'Merge request that logged time was added to.'
|
2021-05-06 12:10:38 +00:00
|
|
|
|
2021-03-23 03:09:04 +00:00
|
|
|
field :note,
|
|
|
|
Types::Notes::NoteType,
|
|
|
|
null: true,
|
2021-08-31 15:10:29 +00:00
|
|
|
description: 'Note where the quick action was executed to add the logged time.'
|
2021-03-23 03:09:04 +00:00
|
|
|
|
2021-07-29 15:09:48 +00:00
|
|
|
field :summary, GraphQL::Types::String,
|
|
|
|
null: true,
|
2021-08-31 15:10:29 +00:00
|
|
|
description: 'Summary of how the time was spent.'
|
2021-07-29 15:09:48 +00:00
|
|
|
|
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
|