# Class Milestone < ActiveRecord::Base

- app/models/milestone.rb

## Schema Information

Table name: milestones

    id          :integer          not null, primary key
    title       :string(255)      not null
    project_id  :integer          not null
    description :text
    due_date    :date
    closed      :boolean          default(FALSE), not null
    created_at  :datetime         not null
    updated_at  :datetime         not null

Methods

A
  - author_id
C
  - can_be_closed?,
  - closed_items_count
E
  - expired?,
  - expires_at
I
  - is_empty?
O
  - open?,
  - open_items_count
P
  - participants,
  - percent_complete
T
  - total_items_count

Attributes

[RW] | author_id_of_changes |

Instance Public methods
author_id() Link

Source: show

    # File app/models/milestone.rb, line 82
    def author_id
      author_id_of_changes
    end

can_be_closed?() Link

Source: show

    # File app/models/milestone.rb, line 70
    def can_be_closed?
      open? && issues.opened.count.zero?
    end

closed_items_count() Link

Source: show

    # File app/models/milestone.rb, line 46
    def closed_items_count
      self.issues.closed.count + self.merge_requests.closed.count
    end

expired?() Link

Source: show

    # File app/models/milestone.rb, line 30
    def expired?
      if due_date
        due_date.past?
      else
        false
      end
    end

expires_at() Link

Source: show

    # File app/models/milestone.rb, line 60
    def expires_at
      if due_date
        if due_date.past?
          "expired at #{due_date.stamp("Aug 21, 2011")}"
        else
          "expires at #{due_date.stamp("Aug 21, 2011")}"
        end
      end
    end

is_empty?() Link

Source: show

    # File app/models/milestone.rb, line 74
    def is_empty?
      total_items_count.zero?
    end

open?() Link

Source: show

    # File app/models/milestone.rb, line 78
    def open?
      !closed
    end

open_items_count() Link

Source: show

    # File app/models/milestone.rb, line 42
    def open_items_count
      self.issues.opened.count + self.merge_requests.opened.count
    end

participants() Link

Source: show

    # File app/models/milestone.rb, line 38
    def participants
      User.where(id: issues.pluck(:assignee_id))
    end

percent_complete() Link

Source: show

    # File app/models/milestone.rb, line 54
    def percent_complete
      ((closed_items_count * 100) / total_items_count).abs
    rescue ZeroDivisionError
      100
    end

total_items_count() Link

Source: show

    # File app/models/milestone.rb, line 50
    def total_items_count
      self.issues.count + self.merge_requests.count
    end