Skip to content

Commit 8f0ba8f

Browse files
Copilotmaebeale
andauthored
Remove obsolete POST search endpoints for workshops and resources (#1035)
* Initial plan * Remove old workshops and resources search endpoints and Search class Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
1 parent 4868c31 commit 8f0ba8f

5 files changed

Lines changed: 1 addition & 136 deletions

File tree

app/assets/javascripts/components/side_nav.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ function setActiveMenuItem() {
4545
link = $('.js-resources');
4646
}
4747
break;
48-
case '/resources/search':
49-
link = $('.js-resources');
50-
break;
5148
case '/resources/' + digit(path):
5249
link = $('.js-resources');
5350
break;
@@ -61,9 +58,6 @@ function setActiveMenuItem() {
6158
case '/workshops/' + digit(path):
6259
link = $('.js-search');
6360
break;
64-
case '/workshops/search':
65-
link = $('.js-search');
66-
break;
6761
case '/workshops/new':
6862
case '/workshop_logs/new':
6963
subMenu = $('.js-report');

app/controllers/resources_controller.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,6 @@ def destroy
121121
redirect_to resources_path, notice: "Resource was successfully destroyed."
122122
end
123123

124-
def search
125-
authorize!
126-
process_search
127-
@sortable_fields = Resource::PUBLISHED_KINDS
128-
render :index
129-
end
130-
131124
def download
132125
@resource = Resource.find(params[:resource_id])
133126
authorize! @resource
@@ -180,12 +173,6 @@ def assign_associations(resource)
180173
resource.save!
181174
end
182175

183-
def process_search
184-
@params = search_params
185-
@query = search_params[:query]
186-
@resources = Search.new.search(search_params, current_user).paginate(page: params[:search][:page])
187-
end
188-
189176
def resource_id_param
190177
params[:id]
191178
end
@@ -211,8 +198,4 @@ def load_forms
211198
end
212199
end
213200
end
214-
215-
def search_params
216-
params[:search]
217-
end
218201
end

app/controllers/workshops_controller.rb

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,6 @@ def update
173173
end
174174

175175

176-
def search
177-
@params = params[:search]
178-
@query = params[:search][:query] if @params
179-
@workshops = Search.new.search(@params, current_user)
180-
181-
if @workshops.paginate(page: params[:search][:page], per_page: workshops_per_page).empty?
182-
@workshops = @workshops.paginate(page: 1, per_page: workshops_per_page)
183-
else
184-
@workshops = @workshops.paginate(page: params[:search][:page], per_page: workshops_per_page)
185-
end
186-
187-
authorize! @workshops
188-
189-
load_sortable_fields
190-
load_metadata
191-
192-
render :index
193-
end
194-
195176
private
196177

197178
def set_show
@@ -241,14 +222,6 @@ def log_workshop_error(action, error)
241222
Rails.logger.error "Workshop #{action} failed: #{error.class} - #{error.message}\n#{error.backtrace.join("\n")}"
242223
end
243224

244-
def workshops_per_page
245-
view_all_workshops? ? @workshops.published.size : 12
246-
end
247-
248-
def view_all_workshops?
249-
params[:search][:view_all] == "1"
250-
end
251-
252225
def workshop_params
253226
params.require(:workshop).permit(
254227
:title, :featured, :published,
@@ -323,12 +296,4 @@ def workshop_params
323296
:position, :_destroy ]
324297
)
325298
end
326-
327-
def load_sortable_fields
328-
@sortable_fields = WindowsType.where(short_name: "COMBINED")
329-
end
330-
331-
def load_metadata
332-
@metadata = CategoryType.includes(:categories).published.decorate
333-
end
334299
end

app/services/search.rb

Lines changed: 0 additions & 70 deletions
This file was deleted.

config/routes.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@
116116

117117
resources :resources do
118118
get :download
119-
collection do
120-
post :search
121-
end
122119
end
123120
resources :sectors do
124121
collection do
@@ -145,11 +142,7 @@
145142
resources :workshop_log_creation_wizard
146143
resources :workshop_variation_ideas
147144
resources :workshop_variations
148-
resources :workshops do
149-
collection do
150-
post :search
151-
end
152-
end
145+
resources :workshops
153146

154147
resources :workshop_mentions, only: [ :index ]
155148
resources :resource_mentions, only: [ :index ]

0 commit comments

Comments
 (0)