Module: API::Helpers::AwardEmoji

Defined in:
lib/api/helpers/award_emoji.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.awardable_id_descObject


14
15
16
# File 'lib/api/helpers/award_emoji.rb', line 14

def self.awardable_id_desc
  "The ID of an Issue, Merge Request or Snippet"
end

.awardablesObject


6
7
8
9
10
11
12
# File 'lib/api/helpers/award_emoji.rb', line 6

def self.awardables
  [
    { type: 'issue', resource: :projects, find_by: :iid, feature_category: :team_planning },
    { type: 'merge_request', resource: :projects, find_by: :iid, feature_category: :code_review },
    { type: 'snippet', resource: :projects, find_by: :id, feature_category: :snippets }
  ]
end

Instance Method Details

#awardableObject

rubocop: disable CodeReuse/ActiveRecord


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/api/helpers/award_emoji.rb', line 19

def awardable
  @awardable ||=
    begin
      if params.include?(:note_id)
        note_id = params.delete(:note_id)

        awardable.notes.find(note_id)
      elsif params.include?(:issue_iid)
        user_project.issues.find_by!(iid: params[:issue_iid])
      elsif params.include?(:merge_request_iid)
        user_project.merge_requests.find_by!(iid: params[:merge_request_iid])
      elsif params.include?(:snippet_id)
        user_project.snippets.find(params[:snippet_id])
      end
    end
end