2020-02-03 13:08:46 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class IssueBasic < IssuableEntity
|
2021-05-05 08:10:33 -04:00
|
|
|
format_with(:upcase) do |item|
|
|
|
|
item.upcase if item.respond_to?(:upcase)
|
|
|
|
end
|
|
|
|
|
2020-02-03 13:08:46 -05:00
|
|
|
expose :closed_at
|
|
|
|
expose :closed_by, using: Entities::UserBasic
|
|
|
|
|
|
|
|
expose :labels do |issue, options|
|
|
|
|
if options[:with_labels_details]
|
|
|
|
::API::Entities::LabelBasic.represent(issue.labels.sort_by(&:title))
|
|
|
|
else
|
|
|
|
issue.labels.map(&:title).sort
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :milestone, using: Entities::Milestone
|
|
|
|
expose :assignees, :author, using: Entities::UserBasic
|
2021-05-05 08:10:33 -04:00
|
|
|
expose :issue_type,
|
|
|
|
as: :type,
|
|
|
|
format_with: :upcase,
|
2021-08-12 02:10:10 -04:00
|
|
|
documentation: { type: "String", desc: "One of #{::WorkItem::Type.base_types.keys.map(&:upcase)}" }
|
2020-02-03 13:08:46 -05:00
|
|
|
|
|
|
|
expose :assignee, using: ::API::Entities::UserBasic do |issue|
|
|
|
|
issue.assignees.first
|
|
|
|
end
|
|
|
|
|
2020-07-10 02:09:23 -04:00
|
|
|
expose(:user_notes_count) { |issue, options| issuable_metadata.user_notes_count }
|
|
|
|
expose(:merge_requests_count) { |issue, options| issuable_metadata.merge_requests_count }
|
|
|
|
expose(:upvotes) { |issue, options| issuable_metadata.upvotes }
|
|
|
|
expose(:downvotes) { |issue, options| issuable_metadata.downvotes }
|
2020-02-03 13:08:46 -05:00
|
|
|
expose :due_date
|
|
|
|
expose :confidential
|
|
|
|
expose :discussion_locked
|
2021-05-05 14:10:31 -04:00
|
|
|
expose :issue_type
|
2020-02-03 13:08:46 -05:00
|
|
|
|
|
|
|
expose :web_url do |issue|
|
|
|
|
Gitlab::UrlBuilder.build(issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |issue|
|
|
|
|
issue
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :task_completion_status
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-02-17 07:09:20 -05:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
API::Entities::IssueBasic.prepend_mod_with('API::Entities::IssueBasic', with_descendants: true)
|