summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/runners_controller.rb2
-rw-r--r--app/controllers/runners_controller.rb2
-rw-r--r--app/models/application_setting.rb1
-rw-r--r--app/models/build.rb2
-rw-r--r--app/models/commit.rb2
-rw-r--r--app/models/event.rb2
-rw-r--r--app/models/project.rb14
-rw-r--r--app/models/runner.rb4
-rw-r--r--app/models/runner_project.rb2
-rw-r--r--app/models/service.rb2
-rw-r--r--app/models/trigger.rb2
-rw-r--r--app/models/trigger_request.rb2
-rw-r--r--app/models/user.rb2
-rw-r--r--app/models/variable.rb2
-rw-r--r--app/models/web_hook.rb2
-rw-r--r--app/services/register_build_service.rb2
16 files changed, 34 insertions, 11 deletions
diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb
index 3cb37f5..ea1119a 100644
--- a/app/controllers/admin/runners_controller.rb
+++ b/app/controllers/admin/runners_controller.rb
@@ -12,7 +12,7 @@ class Admin::RunnersController < Admin::ApplicationController
@builds = @runner.builds.order('id DESC').first(30)
@projects = Project.all
@projects = @projects.search(params[:search]) if params[:search].present?
- @projects = @projects.where("projects.id NOT IN (?)", @runner.projects.pluck(:id)) if @runner.projects.any?
+ @projects = @projects.where("ci_projects.id NOT IN (?)", @runner.projects.pluck(:id)) if @runner.projects.any?
@projects = @projects.page(params[:page]).per(30)
end
diff --git a/app/controllers/runners_controller.rb b/app/controllers/runners_controller.rb
index 2efa637..f7e770c 100644
--- a/app/controllers/runners_controller.rb
+++ b/app/controllers/runners_controller.rb
@@ -10,7 +10,7 @@ class RunnersController < ApplicationController
def index
@runners = @project.runners.order('id DESC')
@specific_runners = current_user.authorized_runners.
- where.not(id: @runners).order('runners.id DESC').page(params[:page]).per(20)
+ where.not(id: @runners).order('ci_runners.id DESC').page(params[:page]).per(20)
@shared_runners = Runner.shared.active
@shared_runners_count = @shared_runners.count(:all)
end
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index f68f10a..e92a115 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -10,6 +10,7 @@
#
class ApplicationSetting < ActiveRecord::Base
+ extend Model
def self.current
ApplicationSetting.last
diff --git a/app/models/build.rb b/app/models/build.rb
index 913a47c..eb29332 100644
--- a/app/models/build.rb
+++ b/app/models/build.rb
@@ -24,6 +24,8 @@
#
class Build < ActiveRecord::Base
+ extend Model
+
LAZY_ATTRIBUTES = ['trace']
belongs_to :commit
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 98bd35c..be260f1 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -16,6 +16,8 @@
#
class Commit < ActiveRecord::Base
+ extend Model
+
belongs_to :project
has_many :builds, dependent: :destroy
has_many :trigger_requests, dependent: :destroy
diff --git a/app/models/event.rb b/app/models/event.rb
index 185ebf1..e1f943d 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -12,6 +12,8 @@
#
class Event < ActiveRecord::Base
+ extend Model
+
belongs_to :project
validates :description,
diff --git a/app/models/project.rb b/app/models/project.rb
index 9b8815e..0fabd17 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -26,6 +26,8 @@
#
class Project < ActiveRecord::Base
+ extend Model
+
include ProjectStatus
has_many :commits, ->() { order('CASE WHEN commits.committed_at IS NULL THEN 0 ELSE 1 END', :committed_at, :id) }, dependent: :destroy
@@ -105,19 +107,19 @@ ls -la
end
def unassigned(runner)
- joins('LEFT JOIN runner_projects ON runner_projects.project_id = projects.id ' \
- "AND runner_projects.runner_id = #{runner.id}").
- where('runner_projects.project_id' => nil)
+ joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.project_id = ci_projects.id ' \
+ "AND ci_runner_projects.runner_id = #{runner.id}").
+ where('ci_runner_projects.project_id' => nil)
end
def ordered_by_last_commit_date
- last_commit_subquery = "(SELECT project_id, MAX(committed_at) committed_at FROM commits GROUP BY project_id)"
- joins("LEFT JOIN #{last_commit_subquery} AS last_commit ON projects.id = last_commit.project_id").
+ last_commit_subquery = "(SELECT project_id, MAX(committed_at) committed_at FROM ci_commits GROUP BY project_id)"
+ joins("LEFT JOIN #{last_commit_subquery} AS last_commit ON ci_projects.id = last_commit.project_id").
order("CASE WHEN last_commit.committed_at IS NULL THEN 1 ELSE 0 END, last_commit.committed_at DESC")
end
def search(query)
- where('LOWER(projects.name) LIKE :query',
+ where('LOWER(ci_projects.name) LIKE :query',
query: "%#{query.try(:downcase)}%")
end
end
diff --git a/app/models/runner.rb b/app/models/runner.rb
index a0a198c..d3417bd 100644
--- a/app/models/runner.rb
+++ b/app/models/runner.rb
@@ -18,6 +18,8 @@
#
class Runner < ActiveRecord::Base
+ extend Model
+
has_many :builds
has_many :runner_projects, dependent: :destroy
has_many :projects, through: :runner_projects
@@ -34,7 +36,7 @@ class Runner < ActiveRecord::Base
acts_as_taggable
def self.search(query)
- where('LOWER(runners.token) LIKE :query OR LOWER(runners.description) like :query',
+ where('LOWER(ci_runners.token) LIKE :query OR LOWER(ci_runners.description) like :query',
query: "%#{query.try(:downcase)}%")
end
diff --git a/app/models/runner_project.rb b/app/models/runner_project.rb
index 6907677..e39a273 100644
--- a/app/models/runner_project.rb
+++ b/app/models/runner_project.rb
@@ -10,6 +10,8 @@
#
class RunnerProject < ActiveRecord::Base
+ extend Model
+
belongs_to :runner
belongs_to :project
diff --git a/app/models/service.rb b/app/models/service.rb
index 714d4a9..ad225ab 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -15,6 +15,8 @@
# To add new service you should build a class inherited from Service
# and implement a set of methods
class Service < ActiveRecord::Base
+ extend Model
+
serialize :properties, JSON
default_value_for :active, false
diff --git a/app/models/trigger.rb b/app/models/trigger.rb
index 26d9893..e2dc186 100644
--- a/app/models/trigger.rb
+++ b/app/models/trigger.rb
@@ -11,6 +11,8 @@
#
class Trigger < ActiveRecord::Base
+ extend Model
+
acts_as_paranoid
belongs_to :project
diff --git a/app/models/trigger_request.rb b/app/models/trigger_request.rb
index 180c23f..5b0861b 100644
--- a/app/models/trigger_request.rb
+++ b/app/models/trigger_request.rb
@@ -11,6 +11,8 @@
#
class TriggerRequest < ActiveRecord::Base
+ extend Model
+
belongs_to :trigger
belongs_to :commit
has_many :builds
diff --git a/app/models/user.rb b/app/models/user.rb
index 2dd80dd..c934dd8 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -67,7 +67,7 @@ class User
def authorized_runners
Runner.specific.includes(:runner_projects).
- where(runner_projects: { project_id: authorized_projects } )
+ where(ci_runner_projects: { project_id: authorized_projects } )
end
def authorized_projects
diff --git a/app/models/variable.rb b/app/models/variable.rb
index c084b89..82d6c4e 100644
--- a/app/models/variable.rb
+++ b/app/models/variable.rb
@@ -12,6 +12,8 @@
#
class Variable < ActiveRecord::Base
+ extend Model
+
belongs_to :project
validates_presence_of :key
diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb
index 9a284d8..5465684 100644
--- a/app/models/web_hook.rb
+++ b/app/models/web_hook.rb
@@ -10,6 +10,8 @@
#
class WebHook < ActiveRecord::Base
+ extend Model
+
include HTTParty
belongs_to :project
diff --git a/app/services/register_build_service.rb b/app/services/register_build_service.rb
index b15e762..c04b6a1 100644
--- a/app/services/register_build_service.rb
+++ b/app/services/register_build_service.rb
@@ -7,7 +7,7 @@ class RegisterBuildService
builds =
if current_runner.shared?
# don't run projects which have not enables shared runners
- builds.includes(:project).where(projects: { shared_runners_enabled: true })
+ builds.includes(:project).where(ci_projects: { shared_runners_enabled: true })
else
# do run projects which are only assigned to this runner
builds.where(project_id: current_runner.projects)