milestone_formatter.rb 816 Bytes
Newer Older
1 2
# frozen_string_literal: true

3
module Gitlab
4
  module LegacyGithubImport
5 6 7
    class MilestoneFormatter < BaseFormatter
      def attributes
        {
8
          iid: number,
9
          project: project,
10 11 12
          title: raw_data.title,
          description: raw_data.description,
          due_date: raw_data.due_on,
13
          state: state,
14 15
          created_at: raw_data.created_at,
          updated_at: raw_data.updated_at
16 17 18
        }
      end

19 20 21 22 23
      def project_association
        :milestones
      end

      def find_condition
24
        { iid: number }
Kim "BKC" Carlbäcker's avatar
Kim "BKC" Carlbäcker committed
25 26
      end

27
      def number
Rémy Coutable's avatar
Rémy Coutable committed
28
        if project.gitea_import?
29 30 31 32
          raw_data.id
        else
          raw_data.number
        end
33 34
      end

35 36 37 38 39 40 41 42
      private

      def state
        raw_data.state == 'closed' ? 'closed' : 'active'
      end
    end
  end
end