mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
cache last event and optimise last subscript api
This commit is contained in:
parent
0bb4665b4a
commit
68e45c0460
@ -4,13 +4,14 @@ class API::EventsController < API::ApiController
|
||||
def index
|
||||
@events = policy_scope(Event)
|
||||
@total = @events.count
|
||||
@events = @events.page(params[:page]).per(12)
|
||||
@page = params[:page]
|
||||
@events = @events.page(@page).per(12)
|
||||
end
|
||||
|
||||
# GET /events/upcoming/:limit
|
||||
def upcoming
|
||||
limit = params[:limit]
|
||||
@events = Event.includes(:event_image, :event_files, :availability)
|
||||
@events = Event.includes(:event_image, :event_files, :availability, :categories)
|
||||
.where('availabilities.start_at >= ?', Time.now)
|
||||
.order('availabilities.start_at ASC').references(:availabilities).limit(limit)
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ class API::MembersController < API::ApiController
|
||||
end
|
||||
|
||||
def last_subscribed
|
||||
@members = User.active.with_role(:member).includes(:profile).where('is_allow_contact = true AND confirmed_at IS NOT NULL').order('created_at desc').limit(params[:last])
|
||||
@members = User.active.with_role(:member).includes(profile: [:user_avatar]).where('is_allow_contact = true AND confirmed_at IS NOT NULL').order('created_at desc').limit(params[:last])
|
||||
@requested_attributes = ['profile']
|
||||
render :index
|
||||
end
|
||||
|
@ -1,6 +1,7 @@
|
||||
json.array!(@events) do |event|
|
||||
json.partial! 'api/events/event', event: event
|
||||
json.event_image_medium event.event_image.attachment.medium.url if event.event_image
|
||||
json.url event_url(event, format: :json)
|
||||
json.cache! @events do
|
||||
json.array!(@events) do |event|
|
||||
json.partial! 'api/events/event', event: event
|
||||
json.event_image_medium event.event_image.attachment.medium.url if event.event_image
|
||||
json.url event_url(event, format: :json)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user