mirror of
https://github.com/wahyd4/libr-2.git
synced 2026-08-09 05:15:53 +10:00
#13 有了timeline source, timeline api的按时间排序变得好简单。
This commit is contained in:
@@ -15,9 +15,8 @@ class Api::V1::TimelineController < Api::V1::ApplicationController
|
||||
def index
|
||||
if @current_user
|
||||
stars_ids = @current_user.stars.ids
|
||||
shared_posts_ids = ShareInstance.where(user_id: stars_ids).order(created_at: :desc).pluck(:sharable_id)
|
||||
# liked_posts_ids = Like.where(user_id: stars_ids).order(created_at: :desc).pluck(:likable_id)
|
||||
render json: Post.find(shared_posts_ids).index_by(&:id).slice(*shared_posts_ids).values, each_serializer: EachPostSerializer
|
||||
posts_ids = TimelineSource.where(user_id: stars_ids).order(created_at: :desc).pluck(:post_id)
|
||||
render json: Post.find(posts_ids).index_by(&:id).slice(*posts_ids).values, each_serializer: EachPostSerializer
|
||||
else
|
||||
return most_liked
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user