mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-30 02:38:47 -04:00
16 lines
474 B
Ruby
16 lines
474 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
module V1
|
|
class CropsController < BaseController
|
|
def search
|
|
proxy = CropResource.all(params.merge(stats: { total: :count }), Crop.search_by_name(params[:term]))
|
|
total = proxy.stats[:total][:count]
|
|
size = proxy.query.pagination[:size] || CropResource.default_page_size
|
|
|
|
render jsonapi: proxy, meta: { record_count: total, page_count: (total / size.to_f).ceil }
|
|
end
|
|
end
|
|
end
|
|
end
|