Add favorites to parties
This commit is contained in:
parent
a99f0c31c5
commit
5d45b8898e
1 changed files with 7 additions and 1 deletions
|
|
@ -36,6 +36,8 @@ class Api::V1::UsersController < Api::V1::ApiController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if @user
|
if @user
|
||||||
|
@per_page = 15
|
||||||
|
|
||||||
now = DateTime.current
|
now = DateTime.current
|
||||||
start_time = (now - params['recency'].to_i.seconds).to_datetime.beginning_of_day unless request.params['recency'].blank?
|
start_time = (now - params['recency'].to_i.seconds).to_datetime.beginning_of_day unless request.params['recency'].blank?
|
||||||
|
|
||||||
|
|
@ -45,10 +47,14 @@ class Api::V1::UsersController < Api::V1::ApiController
|
||||||
conditions[:created_at] = start_time..now unless request.params['recency'].blank?
|
conditions[:created_at] = start_time..now unless request.params['recency'].blank?
|
||||||
conditions[:user_id] = @user.id
|
conditions[:user_id] = @user.id
|
||||||
|
|
||||||
@parties = Party.where(conditions).paginate(page: request.params[:page], per_page: 15)
|
@parties = Party
|
||||||
|
.where(conditions)
|
||||||
|
.order(created_at: :desc)
|
||||||
|
.paginate(page: request.params[:page], per_page: @per_page)
|
||||||
.each { |party|
|
.each { |party|
|
||||||
party.favorited = (current_user) ? party.is_favorited(current_user) : false
|
party.favorited = (current_user) ? party.is_favorited(current_user) : false
|
||||||
}
|
}
|
||||||
|
@count = Party.where(conditions).count
|
||||||
else
|
else
|
||||||
render_not_found_response
|
render_not_found_response
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue