<commit_before>class HomeController < ApplicationController
  skip_before_filter :authenticate_user!, only: :dashboard_data
  skip_before_filter :require_signin_permission!, only: :dashboard_data

  def index
  end

  def dashboard_data
    categories = []
    series = [{ name: "Published", data: [] }, { name: "Completed", data: [] }, { name: "In progress", data: [] }, { name: "Not started", data: []}] 
    Content.tag_counts_on(:tags).to_a.sort{|a,b| a.name <=> b.name}.each do |tag|
      # split platforms

      #mainstream published
      if Content.tagged_with(tag.name).where(platform: "Mainstream")
        categories << "#{tag.name} (M)"
        series[0][:data] << Content.tagged_with(tag.name).where(status: "Published", platform: "Mainstream").sum("size")
        series[1][:data] << Content.tagged_with(tag.name).where(status: "Completed", platform: "Mainstream").sum("size")
        series[2][:data] << Content.tagged_with(tag.name).where(status: "In progress", platform: "Mainstream").sum("size")
        series[3][:data] << Content.tagged_with(tag.name).where(status: "Not started", platform: "Mainstream").sum("size")
      end

      #Whitehall published
      if Content.tagged_with(tag.name).where(platform: "Whitehall")
        categories << "#{tag.name} (W)"
        series[0][:data] << Content.tagged_with(tag.name).where(status: "Published", platform: "Whitehall").sum("size")
        series[1][:data] << Content.tagged_with(tag.name).where(status: "Completed", platform: "Whitehall").sum("size")
        series[2][:data] << Content.tagged_with(tag.name).where(status: "In progress", platform: "Whitehall").sum("size")
        series[3][:data] << Content.tagged_with(tag.name).where(status: "Not started", platform: "Whitehall").sum("size")
      end
    end

    resp = { 
      xAxis: { categories: categories },
      series: series
    }
<commit_msg>Fix checking of content on the chart<commit_after>class HomeController < ApplicationController
  skip_before_filter :authenticate_user!, only: :dashboard_data
  skip_before_filter :require_signin_permission!, only: :dashboard_data

  def index
  end

  def dashboard_data
    categories = []
    series = [{ name: "Published", data: [] }, { name: "Completed", data: [] }, { name: "In progress", data: [] }, { name: "Not started", data: []}] 
    Content.tag_counts_on(:tags).to_a.sort{|a,b| a.name <=> b.name}.each do |tag|
      # split platforms

      #mainstream published
      if Content.tagged_with(tag.name).where(platform: "Mainstream").any?
        categories << "#{tag.name} (M)"
        series[0][:data] << Content.tagged_with(tag.name).where(status: "Published", platform: "Mainstream").sum("size")
        series[1][:data] << Content.tagged_with(tag.name).where(status: "Completed", platform: "Mainstream").sum("size")
        series[2][:data] << Content.tagged_with(tag.name).where(status: "In progress", platform: "Mainstream").sum("size")
        series[3][:data] << Content.tagged_with(tag.name).where(status: "Not started", platform: "Mainstream").sum("size")
      end

      #Whitehall published
      if Content.tagged_with(tag.name).where(platform: "Whitehall").any?
        categories << "#{tag.name} (W)"
        series[0][:data] << Content.tagged_with(tag.name).where(status: "Published", platform: "Whitehall").sum("size")
        series[1][:data] << Content.tagged_with(tag.name).where(status: "Completed", platform: "Whitehall").sum("size")
        series[2][:data] << Content.tagged_with(tag.name).where(status: "In progress", platform: "Whitehall").sum("size")
        series[3][:data] << Content.tagged_with(tag.name).where(status: "Not started", platform: "Whitehall").sum("size")
      end
    end

    resp = { 
      xAxis: { categories: categories },
      series: series
    }

{'fraction_non_alphanumeric': 0.1790887542796945, 'fraction_numerical': 0.004213853041875165, 'mean_word_length': 4.19562243502052, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 5, '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': '4103429', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1160, 'n_words': 222}