mysql - Activerecord group/order by existing array -
my db schema
- user (id,name etc)
- video-stream (id ,userid, viewercount) - one-to-one (a user can have 1 video stream)
- followed_streams (userid,streamid) - many many table (a user can follow many streams , streams can followed multiple users)
my /streams url has below way sort data recieved mysql
@streams = stream.order(viewers: :desc).page(params[:page]).per_page(16)
basically, results being sorted viewer count
i want add function sorts initial table showing followed streams first followed streams show in first result.
i have below gives me array of streamids user has followed this
@followed_streams = followed_streams.where('user_id': @user.id)
is there way can cross-reference @followed_streams
initial stream
table , sort followed ids top?
Comments
Post a Comment