mysql - Activerecord group/order by existing array -


my db schema

  1. user (id,name etc)
  2. video-stream (id ,userid, viewercount) - one-to-one (a user can have 1 video stream)
  3. 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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -