Commit 5a214ee6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove unused methods

parent e3d7ce2c
...@@ -13,12 +13,12 @@ class CommitLoadContext < BaseContext ...@@ -13,12 +13,12 @@ class CommitLoadContext < BaseContext
if commit if commit
commit = CommitDecorator.decorate(commit) commit = CommitDecorator.decorate(commit)
line_notes = project.commit_line_notes(commit) line_notes = project.notes.for_commit_id(commit.id).inline
result[:commit] = commit result[:commit] = commit
result[:note] = project.build_commit_note(commit) result[:note] = project.build_commit_note(commit)
result[:line_notes] = line_notes result[:line_notes] = line_notes
result[:notes_count] = line_notes.count + project.commit_notes(commit).count result[:notes_count] = project.notes.for_commit_id(commit.id).count
begin begin
result[:suppress_diff] = true if commit.diffs.size > Commit::DIFF_SAFE_SIZE && !params[:force_show_diff] result[:suppress_diff] = true if commit.diffs.size > Commit::DIFF_SAFE_SIZE && !params[:force_show_diff]
......
...@@ -9,7 +9,7 @@ module Notes ...@@ -9,7 +9,7 @@ module Notes
@notes = case target_type @notes = case target_type
when "commit" when "commit"
project.commit_notes(project.repository.commit(target_id)).fresh.limit(20) project.notes.for_commit_id(target_id).not_inline.fresh.limit(20)
when "issue" when "issue"
project.issues.find(target_id).notes.inc_author.fresh.limit(20) project.issues.find(target_id).notes.inc_author.fresh.limit(20)
when "merge_request" when "merge_request"
......
...@@ -149,10 +149,6 @@ class Commit ...@@ -149,10 +149,6 @@ class Commit
prev_commit.try :id prev_commit.try :id
end end
def parents_count
parents && parents.count || 0
end
# Shows the diff between the commit's parent and the commit. # Shows the diff between the commit's parent and the commit.
# #
# Cuts out the header and stats from #to_patch and returns only the diff. # Cuts out the header and stats from #to_patch and returns only the diff.
......
...@@ -42,11 +42,11 @@ class Note < ActiveRecord::Base ...@@ -42,11 +42,11 @@ class Note < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader mount_uploader :attachment, AttachmentUploader
# Scopes # Scopes
scope :for_commits, ->{ where(noteable_type: "Commit") } scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
scope :inline, where("line_code IS NOT NULL")
scope :not_inline, where("line_code IS NULL")
scope :common, ->{ where(noteable_type: ["", nil]) } scope :common, ->{ where(noteable_type: ["", nil]) }
scope :today, ->{ where("created_at >= :date", date: Date.today) }
scope :last_week, ->{ where("created_at >= :date", date: (Date.today - 7.days)) }
scope :since, ->(day) { where("created_at >= :date", date: (day)) }
scope :fresh, ->{ order("created_at ASC, id ASC") } scope :fresh, ->{ order("created_at ASC, id ASC") }
scope :inc_author_project, ->{ includes(:project, :author) } scope :inc_author_project, ->{ includes(:project, :author) }
scope :inc_author, ->{ includes(:author) } scope :inc_author, ->{ includes(:author) }
......
...@@ -83,10 +83,6 @@ class Project < ActiveRecord::Base ...@@ -83,10 +83,6 @@ class Project < ActiveRecord::Base
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
class << self class << self
def authorized_for user
raise "DERECATED"
end
def active def active
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
end end
...@@ -215,14 +211,6 @@ class Project < ActiveRecord::Base ...@@ -215,14 +211,6 @@ class Project < ActiveRecord::Base
notes.new(commit_id: commit.id, noteable_type: "Commit") notes.new(commit_id: commit.id, noteable_type: "Commit")
end end
def commit_notes(commit)
notes.where(commit_id: commit.id, noteable_type: "Commit", line_code: nil)
end
def commit_line_notes(commit)
notes.where(commit_id: commit.id, noteable_type: "Commit").where("line_code IS NOT NULL")
end
def last_activity def last_activity
last_event last_event
end end
......
...@@ -230,10 +230,6 @@ class User < ActiveRecord::Base ...@@ -230,10 +230,6 @@ class User < ActiveRecord::Base
abilities.allowed?(self, action, subject) abilities.allowed?(self, action, subject)
end end
def last_activity_project
projects.first
end
def first_name def first_name
name.split.first unless name.blank? name.split.first unless name.blank?
end end
......
...@@ -106,28 +106,6 @@ class UsersProject < ActiveRecord::Base ...@@ -106,28 +106,6 @@ class UsersProject < ActiveRecord::Base
truncate_teams [project.id] truncate_teams [project.id]
end end
def bulk_delete(project, user_ids)
UsersProject.transaction do
UsersProject.where(user_id: user_ids, project_id: project.id).each do |users_project|
users_project.skip_git = true
users_project.destroy
end
project.update_repository
end
end
def bulk_update(project, user_ids, project_access)
UsersProject.transaction do
UsersProject.where(user_id: user_ids, project_id: project.id).each do |users_project|
users_project.project_access = project_access
users_project.skip_git = true
users_project.save
end
project.update_repository
end
end
def roles_hash def roles_hash
{ {
guest: GUEST, guest: GUEST,
...@@ -147,10 +125,6 @@ class UsersProject < ActiveRecord::Base ...@@ -147,10 +125,6 @@ class UsersProject < ActiveRecord::Base
end end
end end
def role_access
project_access
end
def update_repository def update_repository
gitolite.update_repository(project) gitolite.update_repository(project)
end end
......
...@@ -50,5 +50,4 @@ class Wiki < ActiveRecord::Base ...@@ -50,5 +50,4 @@ class Wiki < ActiveRecord::Base
def set_slug def set_slug
self.slug = self.title.parameterize self.slug = self.title.parameterize
end end
end end
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
&nbsp; &nbsp;
%span.notes_count %span.notes_count
- notes = @project.commit_notes(commit) + @project.commit_line_notes(commit) - notes = @project.notes.for_commit_id(commit.id)
- if notes.any? - if notes.any?
%span.btn.small.disabled.grouped %span.btn.disabled.grouped
%i.icon-comment %i.icon-comment
= notes.count = notes.count
...@@ -34,12 +34,6 @@ describe Note do ...@@ -34,12 +34,6 @@ describe Note do
it { should validate_presence_of(:project) } it { should validate_presence_of(:project) }
end end
describe "Scopes" do
it "should have a today named scope that returns ..." do
Note.today.where_values.should == ["created_at >= '#{Date.today}'"]
end
end
describe "Voting score" do describe "Voting score" do
let(:project) { create(:project) } let(:project) { create(:project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment