Read about our upcoming Code of Conduct on this issue

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

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 dc3bdec712b3
......@@ -24,7 +24,7 @@ def activity
def load_events
projects =
if params[:filter] == "starred"
current_user.viewable_starred_projects
ProjectsFinder.new(current_user: current_user, params: { starred: true }).execute
else
current_user.authorized_projects
end
......
......@@ -351,10 +351,6 @@ def search(query)
where("projects.id IN (#{union.to_sql})")
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)
pattern = "%#{query}%"
table = Project.arel_table
......
......@@ -557,12 +557,6 @@ def projects_with_reporter_access_limited_to(projects)
authorized_projects(Gitlab::Access::REPORTER).where(id: projects)
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
@owned_projects ||=
Project.where('namespace_id IN (?) OR namespace_id = ?',
......
......@@ -35,7 +35,7 @@ def filter_projects(projects)
end
if params[:visibility].present?
projects = projects.search_by_visibility(params[:visibility])
projects = projects.where(visibility_level: Gitlab::VisibilityLevel.level_value(params[:visibility]))
end
projects = projects.where(archived: params[:archived])
......
......@@ -147,7 +147,7 @@ def present_projects(projects, options = {})
get '/starred' do
authenticate!
present_projects current_user.viewable_starred_projects
present_projects ProjectsFinder.new(current_user: current_user, params: { starred: true }).execute
end
desc 'Get all projects for admin user' do
......
......@@ -1496,25 +1496,6 @@ def add_user(access)
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
let(:project1) { 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