Commit 1e5506d0 authored by Toon Claes's avatar Toon Claes

Remove some deprecated methods

To avoid the use of slow queries, remove some deprecated methods and encourage
the use of ProjectFinder to find projects.
parent db679788
...@@ -24,7 +24,7 @@ class DashboardController < Dashboard::ApplicationController ...@@ -24,7 +24,7 @@ class DashboardController < Dashboard::ApplicationController
def load_events def load_events
projects = projects =
if params[:filter] == "starred" if params[:filter] == "starred"
current_user.viewable_starred_projects ProjectsFinder.new(current_user: current_user, params: { starred: true }).execute
else else
current_user.authorized_projects current_user.authorized_projects
end end
......
...@@ -351,10 +351,6 @@ class Project < ActiveRecord::Base ...@@ -351,10 +351,6 @@ class Project < ActiveRecord::Base
where("projects.id IN (#{union.to_sql})") where("projects.id IN (#{union.to_sql})")
end end
def search_by_visibility(level) # DEPRECATED: remove with API V3
where(visibility_level: Gitlab::VisibilityLevel.string_options[level])
end
def search_by_title(query) def search_by_title(query)
pattern = "%#{query}%" pattern = "%#{query}%"
table = Project.arel_table table = Project.arel_table
......
...@@ -557,12 +557,6 @@ class User < ActiveRecord::Base ...@@ -557,12 +557,6 @@ class User < ActiveRecord::Base
authorized_projects(Gitlab::Access::REPORTER).where(id: projects) authorized_projects(Gitlab::Access::REPORTER).where(id: projects)
end end
def viewable_starred_projects # DEPRECATED: Use ProjectFinder instead. Remove together with API V3
starred_projects.where("projects.visibility_level IN (?) OR projects.id IN (?)",
[Project::PUBLIC, Project::INTERNAL],
authorized_projects.select(:project_id))
end
def owned_projects def owned_projects
@owned_projects ||= @owned_projects ||=
Project.where('namespace_id IN (?) OR namespace_id = ?', Project.where('namespace_id IN (?) OR namespace_id = ?',
......
...@@ -35,7 +35,7 @@ module API ...@@ -35,7 +35,7 @@ module API
end end
if params[:visibility].present? if params[:visibility].present?
projects = projects.search_by_visibility(params[:visibility]) projects = projects.where(visibility_level: Gitlab::VisibilityLevel.level_value(params[:visibility]))
end end
projects = projects.where(archived: params[:archived]) projects = projects.where(archived: params[:archived])
......
...@@ -147,7 +147,7 @@ module API ...@@ -147,7 +147,7 @@ module API
get '/starred' do get '/starred' do
authenticate! authenticate!
present_projects current_user.viewable_starred_projects present_projects ProjectsFinder.new(current_user: current_user, params: { starred: true }).execute
end end
desc 'Get all projects for admin user' do desc 'Get all projects for admin user' do
......
...@@ -1496,25 +1496,6 @@ describe User, models: true do ...@@ -1496,25 +1496,6 @@ describe User, models: true do
end end
end end
describe '#viewable_starred_projects' do
let(:user) { create(:user) }
let(:public_project) { create(:empty_project, :public) }
let(:private_project) { create(:empty_project, :private) }
let(:private_viewable_project) { create(:empty_project, :private) }
before do
private_viewable_project.team << [user, Gitlab::Access::MASTER]
[public_project, private_project, private_viewable_project].each do |project|
user.toggle_star(project)
end
end
it 'returns only starred projects the user can view' do
expect(user.viewable_starred_projects).not_to include(private_project)
end
end
describe '#projects_with_reporter_access_limited_to' do describe '#projects_with_reporter_access_limited_to' do
let(:project1) { create(:empty_project) } let(:project1) { create(:empty_project) }
let(:project2) { create(:empty_project) } let(:project2) { create(:empty_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