<commit_before>_               = require 'underscore'
Backbone        = require 'backbone'
Genes           = require '../../../../collections/genes.coffee'
{ Following }   = require '../../../../components/follow_button/index.coffee'
priceBuckets    = require '../mixins/price_buckets.coffee'

module.exports =
  initializeGeneArtists: ->
    @geneFollowing = new Following null, kind: 'gene'
    @geneFollowing.fetch
      data: size: 5
      success: (collection, response, options) =>
        @setupGenes collection

  setupGenes: (collection) ->
    @genes = new Genes collection.pluck('gene')
    $.when.apply(null, @genes.map (gene) =>
      gene.trendingArtists.fetch
        data: size: 5
    ).then =>
      @renderGeneSuggestions()

  renderGeneSuggestions: ->
    @genes.each (gene) =>
      @suggestions.add @createGeneSuggestionSet gene
    @renderSuggestions()

  createGeneSuggestionSet: (gene) ->
    new Backbone.Model
      id          : gene.id
      name        : "Suggested for you in #{gene.get 'name'}"
      suggestions : gene.trendingArtists<commit_msg>Include price_range when hitting trending endpoints<commit_after>_               = require 'underscore'
Backbone        = require 'backbone'
Genes           = require '../../../../collections/genes.coffee'
{ Following }   = require '../../../../components/follow_button/index.coffee'
priceBuckets    = require '../mixins/price_buckets.coffee'

module.exports =
  initializeGeneArtists: ->
    @geneFollowing = new Following null, kind: 'gene'
    @geneFollowing.fetch
      data: size: 5
      success: (collection, response, options) =>
        @setupGenes collection

  setupGenes: (collection) ->
    @genes = new Genes collection.pluck('gene')
    $.when.apply(null, @genes.map (gene) =>
      gene.trendingArtists.fetch
        data:
          size        : 5
          price_range : @user.get 'price_range'
    ).then =>
      @renderGeneSuggestions()

  renderGeneSuggestions: ->
    @genes.each (gene) =>
      @suggestions.add @createGeneSuggestionSet gene
    @renderSuggestions()

  createGeneSuggestionSet: (gene) ->
    new Backbone.Model
      id          : gene.id
      name        : "Suggested for you in #{gene.get 'name'}"
      suggestions : gene.trendingArtists
{'fraction_non_alphanumeric': 0.13053097345132744, 'fraction_numerical': 0.0017699115044247787, 'mean_word_length': 2.5054263565891475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6635', 'n_tokens_mistral': 726, 'n_tokens_neox': 654, 'n_words': 147}