<commit_before>class DiscoverController < ApplicationController
  def index
    @interesting = interesting_products.limit(3)
    @profitable = profitable_products.limit(4)
    @greenlit = greenlit_products.limit(20)
    @team_building = team_building_products.limit(20)
    # --
    @products = Product.joins(wips: { taggings: :tag })
                       .where.not(slug: 'meta')
                       .where(flagged_at: nil)
                       .where(state: %w(greenlit profitable team_building))
                       .distinct
                       .limit(100)

    if params[:tag].present?
      # transform tag here so that the label in the HTML is still "writing"
      tag = if params[:tag] == 'writing'
        'copy'
      else
        params[:tag]
      end

      @products = @products.where(wip_tags: { name: tag })
    end

    @products = case params[:sort]
      when 'new'
        @products.order('products.started_team_building_at DESC')
      when 'popular'
        @products.sort_by {|p| -p.partners.size }
      when 'teambuilding'
        @products.sort_by {|p| p.bio_memberships_count }
      else
        @products.ordered_by_trend
      end

  end

  def profitable
    @products = profitable_products.page(params[:page])
  end

  def greenlit
    @products = greenlit_products.page(params[:page])
  end<commit_msg>Only show products with open bounties.<commit_after>class DiscoverController < ApplicationController
  def index
    @interesting = interesting_products.limit(3)
    @profitable = profitable_products.limit(4)
    @greenlit = greenlit_products.limit(20)
    @team_building = team_building_products.limit(20)
    # --
    @products = Product.joins(wips: { taggings: :tag })
                       .where.not(slug: 'meta')
                       .where(flagged_at: nil)
                       .where(state: %w(greenlit profitable team_building))
                       .distinct
                       .limit(100)

    if params[:tag].present?
      # transform tag here so that the label in the HTML is still "writing"
      tag = if params[:tag] == 'writing'
        'copy'
      else
        params[:tag]
      end

      @products = @products.where(
        wip_tags: { name: tag },
        wips: { state: 'open' }
      )
    end

    @products = case params[:sort]
      when 'new'
        @products.order('products.started_team_building_at DESC')
      when 'popular'
        @products.sort_by {|p| -p.partners.size }
      when 'teambuilding'
        @products.sort_by {|p| p.bio_memberships_count }
      else
        @products.ordered_by_trend
      end

  end

  def profitable
    @products = profitable_products.page(params[:page])
  end

  def greenlit
    @products = greenlit_products.page(params[:page])
  end
{'fraction_non_alphanumeric': 0.10533910533910534, 'fraction_numerical': 0.006493506493506494, 'mean_word_length': 2.1873563218390806, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2873228', 'n_tokens_mistral': 848, 'n_tokens_neox': 810, 'n_words': 180}