mirror of
https://github.com/wahyd4/libr-2.git
synced 2026-08-09 05:15:53 +10:00
#43 include current_user"s posts into timeline
This commit is contained in:
@@ -15,7 +15,8 @@ class Api::V1::TimelineController < Api::V1::ApplicationController
|
||||
def index
|
||||
if @current_user
|
||||
stars_ids = @current_user.stars.ids
|
||||
posts_ids = TimelineSource.where(user_id: stars_ids).order(created_at: :desc).page(params[:page]).pluck(:post_id)
|
||||
user_ids = stars_ids + [@current_user.id]
|
||||
posts_ids = TimelineSource.where(user_id: user_ids).order(created_at: :desc).page(params[:page]).pluck(:post_id)
|
||||
render json: Post.find(posts_ids).index_by(&:id).slice(*posts_ids).values, each_serializer: EachPostSerializer
|
||||
else
|
||||
return most_liked
|
||||
|
||||
Reference in New Issue
Block a user