Class: Project
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Project
- Defined in:
- app/models/project.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.add_project(user, name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/project.rb', line 7 def self.add_project(user, name) repo = user.client.repo(name) found = Project.find_by(repo_id: repo[:id]) return found if found project = { name: repo[:name], repo_provider: user.provider, repo_owner: repo[:owner], repo_name: repo[:name], repo_id: repo[:id], } team = user.teams.find_by(provider_id: repo[:owner_id]) if team project[:team] = team else project[:user] = user end create!(project) end |
Instance Method Details
#branches ⇒ Object
35 36 37 38 39 |
# File 'app/models/project.rb', line 35 def branches jobs.group(:branch).limit(20).pluck(:branch).map do |branch| jobs.where(branch: branch).first end end |
#owner ⇒ Object
41 42 43 |
# File 'app/models/project.rb', line 41 def owner user || team end |
#status ⇒ Object
31 32 33 |
# File 'app/models/project.rb', line 31 def status jobs.where(branch: 'master').last.try(:status) end |