Skip to content

Commit

Permalink
Add 'esd' action to ProjectsController and corresponding route
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Mar 6, 2025
1 parent 92bd768 commit 5d2e5d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/controllers/api/v1/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,20 @@ def packages
def images
@projects = Project.reviewed.with_readme.select{|p| p.readme_image_urls.present? }
end

def esd
@projects = Project.all.where.not(last_synced_at: nil).where(est: true)

if params[:sort].present? || params[:order].present?
sort = params[:sort].presence || 'projects.updated_at'
if params[:order] == 'asc'
@projects = @projects.order(Arel.sql(sort).asc.nulls_last)
else
@projects = @projects.order(Arel.sql(sort).desc.nulls_last)
end
end

@pagy, @projects = pagy_countless(@projects)
render :index
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
resources :jobs
resources :projects, constraints: { id: /.*/ }, only: [:index, :show] do
collection do
get :esd
get :lookup
get :packages
get :images
Expand Down

0 comments on commit 5d2e5d9

Please sign in to comment.