Class: Twenty::Project

Inherits:
Sequel::Model
  • Object
show all
Includes:
ColorableMixin, Model
Defined in:
lib/twenty/server/model/project.rb

Constant Summary

Constants included from ColorableMixin

ColorableMixin::COLORS

Instance Method Summary collapse

Methods included from ColorableMixin

#before_validation, #random_color

Methods included from Model

included

Instance Method Details

#open_task_countInteger

Returns the number of open tasks a project has

Returns:

  • (Integer)

    Returns the number of open tasks a project has



36
37
38
39
40
41
# File 'lib/twenty/server/model/project.rb', line 36

def open_task_count
  @open_task_count ||= Twenty::Task
                         .where(project_id: id)
                         .where(Sequel.lit("status IN (0,1,2)"))
                         .count
end

#pathString

Returns The path to a project.

Returns:

  • (String)

    The path to a project



22
23
24
# File 'lib/twenty/server/model/project.rb', line 22

def path
  super&.sub(Dir.home, "~")
end

#path_exist?Boolean

Returns true when #path exists on disk

Returns:

  • (Boolean)

    Returns true when #path exists on disk



29
30
31
# File 'lib/twenty/server/model/project.rb', line 29

def path_exist?
  File.exist? File.expand_path(path)
end

#validateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
16
17
# File 'lib/twenty/server/model/project.rb', line 13

def validate
  super
  errors.add(:path, "does not exist on disk") if !path_exist?
  errors.add(:path, "is not absolute") if !File.absolute_path?(path)
end