Commit 5a214ee6f198a90f41a54b3dd7f2ff6a318a8deb
1 parent
e3d7ce2c
Exists in
master
and in
4 other branches
Remove unused methods
Showing
10 changed files
with
9 additions
and
62 deletions
Show diff stats
app/contexts/commit_load_context.rb
@@ -13,12 +13,12 @@ class CommitLoadContext < BaseContext | @@ -13,12 +13,12 @@ class CommitLoadContext < BaseContext | ||
13 | 13 | ||
14 | if commit | 14 | if commit |
15 | commit = CommitDecorator.decorate(commit) | 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 | result[:commit] = commit | 18 | result[:commit] = commit |
19 | result[:note] = project.build_commit_note(commit) | 19 | result[:note] = project.build_commit_note(commit) |
20 | result[:line_notes] = line_notes | 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 | begin | 23 | begin |
24 | result[:suppress_diff] = true if commit.diffs.size > Commit::DIFF_SAFE_SIZE && !params[:force_show_diff] | 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,7 +9,7 @@ module Notes | ||
9 | 9 | ||
10 | @notes = case target_type | 10 | @notes = case target_type |
11 | when "commit" | 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 | when "issue" | 13 | when "issue" |
14 | project.issues.find(target_id).notes.inc_author.fresh.limit(20) | 14 | project.issues.find(target_id).notes.inc_author.fresh.limit(20) |
15 | when "merge_request" | 15 | when "merge_request" |
app/models/commit.rb
@@ -149,10 +149,6 @@ class Commit | @@ -149,10 +149,6 @@ class Commit | ||
149 | prev_commit.try :id | 149 | prev_commit.try :id |
150 | end | 150 | end |
151 | 151 | ||
152 | - def parents_count | ||
153 | - parents && parents.count || 0 | ||
154 | - end | ||
155 | - | ||
156 | # Shows the diff between the commit's parent and the commit. | 152 | # Shows the diff between the commit's parent and the commit. |
157 | # | 153 | # |
158 | # Cuts out the header and stats from #to_patch and returns only the diff. | 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,11 +42,11 @@ class Note < ActiveRecord::Base | ||
42 | mount_uploader :attachment, AttachmentUploader | 42 | mount_uploader :attachment, AttachmentUploader |
43 | 43 | ||
44 | # Scopes | 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 | scope :common, ->{ where(noteable_type: ["", nil]) } | 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 | scope :fresh, ->{ order("created_at ASC, id ASC") } | 50 | scope :fresh, ->{ order("created_at ASC, id ASC") } |
51 | scope :inc_author_project, ->{ includes(:project, :author) } | 51 | scope :inc_author_project, ->{ includes(:project, :author) } |
52 | scope :inc_author, ->{ includes(:author) } | 52 | scope :inc_author, ->{ includes(:author) } |
app/models/project.rb
@@ -83,10 +83,6 @@ class Project < ActiveRecord::Base | @@ -83,10 +83,6 @@ class Project < ActiveRecord::Base | ||
83 | scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } | 83 | scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } |
84 | 84 | ||
85 | class << self | 85 | class << self |
86 | - def authorized_for user | ||
87 | - raise "DERECATED" | ||
88 | - end | ||
89 | - | ||
90 | def active | 86 | def active |
91 | joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") | 87 | joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") |
92 | end | 88 | end |
@@ -215,14 +211,6 @@ class Project < ActiveRecord::Base | @@ -215,14 +211,6 @@ class Project < ActiveRecord::Base | ||
215 | notes.new(commit_id: commit.id, noteable_type: "Commit") | 211 | notes.new(commit_id: commit.id, noteable_type: "Commit") |
216 | end | 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 | def last_activity | 214 | def last_activity |
227 | last_event | 215 | last_event |
228 | end | 216 | end |
app/models/user.rb
@@ -230,10 +230,6 @@ class User < ActiveRecord::Base | @@ -230,10 +230,6 @@ class User < ActiveRecord::Base | ||
230 | abilities.allowed?(self, action, subject) | 230 | abilities.allowed?(self, action, subject) |
231 | end | 231 | end |
232 | 232 | ||
233 | - def last_activity_project | ||
234 | - projects.first | ||
235 | - end | ||
236 | - | ||
237 | def first_name | 233 | def first_name |
238 | name.split.first unless name.blank? | 234 | name.split.first unless name.blank? |
239 | end | 235 | end |
app/models/users_project.rb
@@ -106,28 +106,6 @@ class UsersProject < ActiveRecord::Base | @@ -106,28 +106,6 @@ class UsersProject < ActiveRecord::Base | ||
106 | truncate_teams [project.id] | 106 | truncate_teams [project.id] |
107 | end | 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 | def roles_hash | 109 | def roles_hash |
132 | { | 110 | { |
133 | guest: GUEST, | 111 | guest: GUEST, |
@@ -147,10 +125,6 @@ class UsersProject < ActiveRecord::Base | @@ -147,10 +125,6 @@ class UsersProject < ActiveRecord::Base | ||
147 | end | 125 | end |
148 | end | 126 | end |
149 | 127 | ||
150 | - def role_access | ||
151 | - project_access | ||
152 | - end | ||
153 | - | ||
154 | def update_repository | 128 | def update_repository |
155 | gitolite.update_repository(project) | 129 | gitolite.update_repository(project) |
156 | end | 130 | end |
app/models/wiki.rb
app/views/commits/_commit.html.haml
@@ -14,8 +14,8 @@ | @@ -14,8 +14,8 @@ | ||
14 | | 14 | |
15 | 15 | ||
16 | %span.notes_count | 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 | - if notes.any? | 18 | - if notes.any? |
19 | - %span.btn.small.disabled.grouped | 19 | + %span.btn.disabled.grouped |
20 | %i.icon-comment | 20 | %i.icon-comment |
21 | = notes.count | 21 | = notes.count |
spec/models/note_spec.rb
@@ -34,12 +34,6 @@ describe Note do | @@ -34,12 +34,6 @@ describe Note do | ||
34 | it { should validate_presence_of(:project) } | 34 | it { should validate_presence_of(:project) } |
35 | end | 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 | describe "Voting score" do | 37 | describe "Voting score" do |
44 | let(:project) { create(:project) } | 38 | let(:project) { create(:project) } |
45 | 39 |