Commit 5a214ee6f198a90f41a54b3dd7f2ff6a318a8deb

Authored by Dmitriy Zaporozhets
1 parent e3d7ce2c

Remove unused methods

app/contexts/commit_load_context.rb
... ... @@ -13,12 +13,12 @@ class CommitLoadContext < BaseContext
13 13  
14 14 if commit
15 15 commit = CommitDecorator.decorate(commit)
16   - line_notes = project.commit_line_notes(commit)
  16 + line_notes = project.notes.for_commit_id(commit.id).inline
17 17  
18 18 result[:commit] = commit
19 19 result[:note] = project.build_commit_note(commit)
20 20 result[:line_notes] = line_notes
21   - result[:notes_count] = line_notes.count + project.commit_notes(commit).count
  21 + result[:notes_count] = project.notes.for_commit_id(commit.id).count
22 22  
23 23 begin
24 24 result[:suppress_diff] = true if commit.diffs.size > Commit::DIFF_SAFE_SIZE && !params[:force_show_diff]
... ...
app/contexts/notes/load_context.rb
... ... @@ -9,7 +9,7 @@ module Notes
9 9  
10 10 @notes = case target_type
11 11 when "commit"
12   - project.commit_notes(project.repository.commit(target_id)).fresh.limit(20)
  12 + project.notes.for_commit_id(target_id).not_inline.fresh.limit(20)
13 13 when "issue"
14 14 project.issues.find(target_id).notes.inc_author.fresh.limit(20)
15 15 when "merge_request"
... ...
app/models/commit.rb
... ... @@ -149,10 +149,6 @@ class Commit
149 149 prev_commit.try :id
150 150 end
151 151  
152   - def parents_count
153   - parents && parents.count || 0
154   - end
155   -
156 152 # Shows the diff between the commit's parent and the commit.
157 153 #
158 154 # Cuts out the header and stats from #to_patch and returns only the diff.
... ...
app/models/note.rb
... ... @@ -42,11 +42,11 @@ class Note < ActiveRecord::Base
42 42 mount_uploader :attachment, AttachmentUploader
43 43  
44 44 # Scopes
45   - scope :for_commits, ->{ where(noteable_type: "Commit") }
  45 + scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
  46 + scope :inline, where("line_code IS NOT NULL")
  47 + scope :not_inline, where("line_code IS NULL")
  48 +
46 49 scope :common, ->{ where(noteable_type: ["", nil]) }
47   - scope :today, ->{ where("created_at >= :date", date: Date.today) }
48   - scope :last_week, ->{ where("created_at >= :date", date: (Date.today - 7.days)) }
49   - scope :since, ->(day) { where("created_at >= :date", date: (day)) }
50 50 scope :fresh, ->{ order("created_at ASC, id ASC") }
51 51 scope :inc_author_project, ->{ includes(:project, :author) }
52 52 scope :inc_author, ->{ includes(:author) }
... ...
app/models/project.rb
... ... @@ -83,10 +83,6 @@ class Project < ActiveRecord::Base
83 83 scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
84 84  
85 85 class << self
86   - def authorized_for user
87   - raise "DERECATED"
88   - end
89   -
90 86 def active
91 87 joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
92 88 end
... ... @@ -215,14 +211,6 @@ class Project &lt; ActiveRecord::Base
215 211 notes.new(commit_id: commit.id, noteable_type: "Commit")
216 212 end
217 213  
218   - def commit_notes(commit)
219   - notes.where(commit_id: commit.id, noteable_type: "Commit", line_code: nil)
220   - end
221   -
222   - def commit_line_notes(commit)
223   - notes.where(commit_id: commit.id, noteable_type: "Commit").where("line_code IS NOT NULL")
224   - end
225   -
226 214 def last_activity
227 215 last_event
228 216 end
... ...
app/models/user.rb
... ... @@ -230,10 +230,6 @@ class User &lt; ActiveRecord::Base
230 230 abilities.allowed?(self, action, subject)
231 231 end
232 232  
233   - def last_activity_project
234   - projects.first
235   - end
236   -
237 233 def first_name
238 234 name.split.first unless name.blank?
239 235 end
... ...
app/models/users_project.rb
... ... @@ -106,28 +106,6 @@ class UsersProject &lt; ActiveRecord::Base
106 106 truncate_teams [project.id]
107 107 end
108 108  
109   - def bulk_delete(project, user_ids)
110   - UsersProject.transaction do
111   - UsersProject.where(user_id: user_ids, project_id: project.id).each do |users_project|
112   - users_project.skip_git = true
113   - users_project.destroy
114   - end
115   -
116   - project.update_repository
117   - end
118   - end
119   -
120   - def bulk_update(project, user_ids, project_access)
121   - UsersProject.transaction do
122   - UsersProject.where(user_id: user_ids, project_id: project.id).each do |users_project|
123   - users_project.project_access = project_access
124   - users_project.skip_git = true
125   - users_project.save
126   - end
127   - project.update_repository
128   - end
129   - end
130   -
131 109 def roles_hash
132 110 {
133 111 guest: GUEST,
... ... @@ -147,10 +125,6 @@ class UsersProject &lt; ActiveRecord::Base
147 125 end
148 126 end
149 127  
150   - def role_access
151   - project_access
152   - end
153   -
154 128 def update_repository
155 129 gitolite.update_repository(project)
156 130 end
... ...
app/models/wiki.rb
... ... @@ -50,5 +50,4 @@ class Wiki &lt; ActiveRecord::Base
50 50 def set_slug
51 51 self.slug = self.title.parameterize
52 52 end
53   -
54 53 end
... ...
app/views/commits/_commit.html.haml
... ... @@ -14,8 +14,8 @@
14 14 &nbsp;
15 15  
16 16 %span.notes_count
17   - - notes = @project.commit_notes(commit) + @project.commit_line_notes(commit)
  17 + - notes = @project.notes.for_commit_id(commit.id)
18 18 - if notes.any?
19   - %span.btn.small.disabled.grouped
  19 + %span.btn.disabled.grouped
20 20 %i.icon-comment
21 21 = notes.count
... ...
spec/models/note_spec.rb
... ... @@ -34,12 +34,6 @@ describe Note do
34 34 it { should validate_presence_of(:project) }
35 35 end
36 36  
37   - describe "Scopes" do
38   - it "should have a today named scope that returns ..." do
39   - Note.today.where_values.should == ["created_at >= '#{Date.today}'"]
40   - end
41   - end
42   -
43 37 describe "Voting score" do
44 38 let(:project) { create(:project) }
45 39  
... ...