app/models/question_sampler.rb
# questions is an ActiveRecordRelation (not an array) of questions
# tags is ActiveRecordRelation (not an array) of tags
# count is a positive integer
questions is an ActiveRecordRelation (not an array) of questions
tags is ActiveRecordRelation (not an array) of tags
count is a positive integer
questions is an ActiveRecordRelation ( not an array ) of questions tags is ActiveRecordRelation ( not an array ) of tags count is a positive integer
def weighted_question_ids
      tag_ids = @tags.pluck(:id)
      weighted_questions = @questions.includes(:tags).map do |q|
        [q.id, (q.tag_ids & tag_ids).count]
      end
      weighted_questions.to_h.reject { |_k, v| v.zero? }
    end
def weighted_question_ids tag_ids = @tags . pluck ( :id ) weighted_questions = @questions . includes ( :tags ) . map do | q | [ q . id , ( q . tag_ids & tag_ids ) . count ] end weighted_questions . to_h . reject { | _k , v | v . zero? } end
questions is an ActiveRecordRelation (not an array) of questions
tags is ActiveRecordRelation (not an array) of tags
count is a positive integer
questions is an ActiveRecordRelation ( not an array ) of questions tags is ActiveRecordRelation ( not an array ) of tags count is a positive integer