Class: CodeChangeActivity

Inherits:
Object
  • Object
show all
Defined in:
lib/models/code_change_activity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



5
6
7
# File 'lib/models/code_change_activity.rb', line 5

def author
  @author
end

#code_changeObject (readonly)

Returns the value of attribute code_change.



5
6
7
# File 'lib/models/code_change_activity.rb', line 5

def code_change
  @code_change
end

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/models/code_change_activity.rb', line 5

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/models/code_change_activity.rb', line 5

def id
  @id
end

#is_selfObject (readonly)

Returns the value of attribute is_self.



5
6
7
# File 'lib/models/code_change_activity.rb', line 5

def is_self
  @is_self
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/models/code_change_activity.rb', line 5

def message
  @message
end

Instance Method Details

#messages_to_ignoreObject

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/models/code_change_activity.rb', line 20

def messages_to_ignore
  raise NotImplementedError
end

#notifiedObject



7
8
9
10
11
# File 'lib/models/code_change_activity.rb', line 7

def notified
  if id
    Rubiclifier::DB.execute("INSERT INTO code_change_activity_notified (id, notified_at) VALUES('#{id}', CURRENT_TIMESTAMP);")
  end
end

#should_notify?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
# File 'lib/models/code_change_activity.rb', line 13

def should_notify?
  !is_self &&
    (code_change.activity_from_self_at && created_at > code_change.activity_from_self_at && code_change.includes_self || message == "just opened merge request") &&
    messages_to_ignore.none? { |m| message.match(m) } &&
    !Rubiclifier::DB.query_single_row("SELECT id FROM code_change_activity_notified WHERE id = '#{id}'")
end