<commit_before>module AuthorsHelper
  def author_publication_history(data)
    years = data.map {|d| d.year }.sort
    years_range = (years.first .. years.last).to_a
    x_axis_label = years_range.map {|y| y == years.first || y == years.last ? y : "" }
    data_by_year = data.group_by(&:year)
    first = years_range.map {|y| data_by_year[y].nil? ? 0 : data_by_year[y][0].first} 
    middle = years_range.map {|y| data_by_year[y].nil? ? 0 : data_by_year[y][0].middle} 
    last = years_range.map {|y| data_by_year[y].nil? ? 0 : data_by_year[y][0].last} 
    articles = [first, middle, last]
    article_max = number_with_delimiter(data.map {|d| d.total}.sort.last)
    bar_chart(articles, x_axis_label, article_max)
  end
  
  def authorship_position(data, period = 'all')<commit_msg>don't show pie chart w/o any data<commit_after>module AuthorsHelper
  def author_publication_history(data)
    years = data.map {|d| d.year }.sort
    years_range = (years.first .. years.last).to_a
    x_axis_label = years_range.map {|y| y == years.first || y == years.last ? y : "" }
    data_by_year = data.group_by(&:year)
    first = years_range.map {|y| data_by_year[y].nil? ? 0 : data_by_year[y][0].first} 
    middle = years_range.map {|y| data_by_year[y].nil? ? 0 : data_by_year[y][0].middle} 
    last = years_range.map {|y| data_by_year[y].nil? ? 0 : data_by_year[y][0].last} 
    articles = [first, middle, last]
    article_max = number_with_delimiter(data.map {|d| d.total}.sort.last)
    bar_chart(articles, x_axis_label, article_max)
  end
  
  def authorship_position(data, period = 'all')
    return if data.send("#{period}_total") == 0
{'fraction_non_alphanumeric': 0.1562881562881563, 'fraction_numerical': 0.007936507936507936, 'mean_word_length': 3.966666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?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': '96775', 'n_tokens_mistral': 641, 'n_tokens_neox': 622, 'n_words': 121}