<commit_before>class Admin::ReportesController < ApplicationController
  layout "administrator"

  # This is Devise's authentication
  before_filter :authenticate_admin!
  
  def chart_carreras
    @careers_count = User.joins(:academic_info)
                         .where(approved: true)
                         .group("academic_infos.carreer")
                         .count

    # Reemplazo el nombre nil por Desconocido
    unknown_career = "Desconocido"
    if @careers_count.has_key?(nil)
      @careers_count[unknown_career] = @careers_count[nil]
      @careers_count.delete(nil)
    end
    logger.debug "[REPORTS] Careers count: #{@careers_count.inspect}"

    @careers = @careers_count.to_a
    logger.debug "[REPORTS] Careers: #{@careers}"

    @total_users = @careers_count.values.inject{|sum,x| sum + x }
    logger.debug "[REPORTS] Total users: #{@total_users}"

    @chart_carreras = LazyHighCharts::HighChart.new('pie') do |f|
          f.chart({
            :defaultSeriesType =>"pie",
            :margin => [50, 100, 50, 100]
            })
          f.series({
            :type => 'pie',
            :name => 'Alumnos',
            :data => @careers
            })
          f.options[:title][:text] = "Carreras de alumnos registrados"
          f.legend(
            :layout=> 'vertical',
            :style => {
              :left => 'auto',
              :bottom => 'auto',
              :right => '50px',
              :top=> '100px'
            })
          f.plot_options(
            :pie => {
              :allowPointSelect => true,
              :cursor => "pointer",
              :dataLabels => {
                :enabled=>true,
                :color=>"black",
                :style => {
                  :font => "13px Trebuchet MS, Verdana, sans-serif"
                }
              }
            })
          f.exporting({
              enabled: false
            })
    end
  end

  def chart_foros
    showed_discussions_max_count = 8   # Numero maximo de discusiones mostradas    
    @userResponseMessage = ""

    #Buscamos si tengo los parametros de fechas
    if (params[:initialDate].nil? or params[:finalDate].nil?)
      @initialDate = "01/01/2015"
      @finalDate = "01/12/2015"
    else
      @initialDate = params[:initialDate]
      @finalDate = params[:finalDate]
      if not validateDateRange
        return
      end
    end  

    # Filtramos los comentarios por fecha<commit_msg>Se agrega la posibilidad de ver mas discusiones para poder reporducir el bug en heroku<commit_after>class Admin::ReportesController < ApplicationController
  layout "administrator"

  # This is Devise's authentication
  before_filter :authenticate_admin!
  
  def chart_carreras
    @careers_count = User.joins(:academic_info)
                         .where(approved: true)
                         .group("academic_infos.carreer")
                         .count

    # Reemplazo el nombre nil por Desconocido
    unknown_career = "Desconocido"
    if @careers_count.has_key?(nil)
      @careers_count[unknown_career] = @careers_count[nil]
      @careers_count.delete(nil)
    end
    logger.debug "[REPORTS] Careers count: #{@careers_count.inspect}"

    @careers = @careers_count.to_a
    logger.debug "[REPORTS] Careers: #{@careers}"

    @total_users = @careers_count.values.inject{|sum,x| sum + x }
    logger.debug "[REPORTS] Total users: #{@total_users}"

    @chart_carreras = LazyHighCharts::HighChart.new('pie') do |f|
          f.chart({
            :defaultSeriesType =>"pie",
            :margin => [50, 100, 50, 100]
            })
          f.series({
            :type => 'pie',
            :name => 'Alumnos',
            :data => @careers
            })
          f.options[:title][:text] = "Carreras de alumnos registrados"
          f.legend(
            :layout=> 'vertical',
            :style => {
              :left => 'auto',
              :bottom => 'auto',
              :right => '50px',
              :top=> '100px'
            })
          f.plot_options(
            :pie => {
              :allowPointSelect => true,
              :cursor => "pointer",
              :dataLabels => {
                :enabled=>true,
                :color=>"black",
                :style => {
                  :font => "13px Trebuchet MS, Verdana, sans-serif"
                }
              }
            })
          f.exporting({
              enabled: false
            })
    end
  end

  def chart_foros
    showed_discussions_max_count = 10   # Numero maximo de discusiones mostradas    
    @userResponseMessage = ""

    #Buscamos si tengo los parametros de fechas
    if (params[:initialDate].nil? or params[:finalDate].nil?)
      @initialDate = "01/01/2015"
      @finalDate = "01/12/2015"
    else
      @initialDate = params[:initialDate]
      @finalDate = params[:finalDate]
      if not validateDateRange
        return
      end
    end  

    # Filtramos los comentarios por fecha
{'fraction_non_alphanumeric': 0.11563255439161967, 'fraction_numerical': 0.013900080580177276, 'mean_word_length': 1.778399552322328, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '664415', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1478, 'n_words': 315}