summaryrefslogtreecommitdiff
path: root/app/models/todo.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/todo.rb')
-rw-r--r--app/models/todo.rb34
1 files changed, 19 insertions, 15 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb
index d9b86d941b6..534db99b9a0 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -24,7 +24,7 @@ class Todo < ActiveRecord::Base
MARKED => :marked,
APPROVAL_REQUIRED => :approval_required,
UNMERGEABLE => :unmergeable,
- DIRECTLY_ADDRESSED => :directly_addressed
+ DIRECTLY_ADDRESSED => :directly_addressed,
}.freeze
belongs_to :author, class_name: "User"
@@ -45,13 +45,13 @@ class Todo < ActiveRecord::Base
scope :pending, -> { with_state(:pending) }
scope :done, -> { with_state(:done) }
- scope :for_action, -> (action) { where(action: action) }
- scope :for_author, -> (author) { where(author: author) }
- scope :for_project, -> (project) { where(project: project) }
- scope :for_group, -> (group) { where(group: group) }
- scope :for_type, -> (type) { where(target_type: type) }
- scope :for_target, -> (id) { where(target_id: id) }
- scope :for_commit, -> (id) { where(commit_id: id) }
+ scope :for_action, ->(action) { where(action: action) }
+ scope :for_author, ->(author) { where(author: author) }
+ scope :for_project, ->(project) { where(project: project) }
+ scope :for_group, ->(group) { where(group: group) }
+ scope :for_type, ->(type) { where(target_type: type) }
+ scope :for_target, ->(id) { where(target_id: id) }
+ scope :for_commit, ->(id) { where(commit_id: id) }
state_machine :state, initial: :pending do
event :done do
@@ -75,7 +75,7 @@ class Todo < ActiveRecord::Base
from_union([
for_project(Project.for_group(groups)),
- for_group(groups)
+ for_group(groups),
])
end
@@ -107,7 +107,7 @@ class Todo < ActiveRecord::Base
def sort_by_attribute(method)
sorted =
case method.to_s
- when 'priority', 'label_priority' then order_by_labels_priority
+ when "priority", "label_priority" then order_by_labels_priority
else order_by(method)
end
@@ -122,14 +122,14 @@ class Todo < ActiveRecord::Base
params = {
target_type_column: "todos.target_type",
target_column: "todos.target_id",
- project_column: "todos.project_id"
+ project_column: "todos.project_id",
}
highest_priority = highest_label_priority(params).to_sql
select("#{table_name}.*, (#{highest_priority}) AS highest_priority")
- .order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC'))
- .order('todos.created_at')
+ .order(Gitlab::Database.nulls_last_order("highest_priority", "ASC"))
+ .order("todos.created_at")
end
end
@@ -168,7 +168,11 @@ class Todo < ActiveRecord::Base
# override to return commits, which are not active record
def target
if for_commit?
- project.commit(commit_id) rescue nil
+ begin
+ project.commit(commit_id)
+ rescue
+ nil
+ end
else
super
end
@@ -193,6 +197,6 @@ class Todo < ActiveRecord::Base
private
def keep_around_commit
- project.repository.keep_around(self.commit_id)
+ project.repository.keep_around(commit_id)
end
end