BigW Consortium Gitlab

milestone_formatter.rb 779 Bytes
Newer Older
1 2 3 4 5
module Gitlab
  module GithubImport
    class MilestoneFormatter < BaseFormatter
      def attributes
        {
6
          iid: number,
7
          project: project,
8 9 10
          title: raw_data.title,
          description: raw_data.description,
          due_date: raw_data.due_on,
11
          state: state,
12 13
          created_at: raw_data.created_at,
          updated_at: raw_data.updated_at
14 15 16
        }
      end

17 18 19 20 21
      def project_association
        :milestones
      end

      def find_condition
22
        { iid: number }
Kim "BKC" Carlbäcker committed
23 24
      end

25
      def number
26
        if project.gitea_import?
27 28 29 30
          raw_data.id
        else
          raw_data.number
        end
31 32
      end

33 34 35 36 37 38 39 40
      private

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