<commit_before>module SessionHelper

  # s is for session. 'session' is reserved word for rails
  def process_stenograph s

    members = Member.select("first_name, last_name, id").map { |m| [m.id, m.first_name + " " + m.last_name] }
    votings = Voting.select("id", "topic").by_session(s).non_registration.ordered.to_a

    stenograph = "<div class='links'>"
    stenograph += votings.map { |v, idx|
      link_to v.topic, "#voting-" + v.id.to_s
    }.join("<br>")
    stenograph += "</div><pre>"
    stenograph += s.stenograph

    stenograph.gsub! "\r\n", "<br>"

    members.each do |m|
      stenograph.gsub! m[1], "<a href='/members/#{m[0]}'>#{m[1]}</a>"
    end

    regex = /Гласували \d+ народни представители: за (\d+|няма), против (\d+|няма), (въздържали се|въздържал се) (\d+|няма|– няма)\./

    regex_enum = stenograph.gsub!(regex)

    regex_enum.each_with_index do |match, idx|
      options = {
       data: { voting: idx },
       class: ["btn", "btn-default", "show-voting"],
       id: "voting-" + votings[idx].id.to_s
      }
      output = button_tag options do
        match
      end
      output += "<br><div id='content-#{idx}'></div>".html_safe
    end
    stenograph + "</pre>"
  end

  def calendar year, &block
    year = (year.beginning_of_year..year.end_of_year).map { |d| Date.new(d.year, d.month, 1) }.uniq.in_groups_of(4)
    content_tag :table, class: "table table-bordered" do
      year.map do |quarter|
        content_tag :tr do
          quarter.map do |month|
            content_tag :td do
              self.capture(month, &block)<commit_msg>Improved session helper a bit.<commit_after>module SessionHelper

  # s is for session. 'session' is reserved word for rails
  def process_stenograph s

    members = s.members.pluck(:id, :first_name, :last_name).map { |m| [m[0], m[1] + " " + m[2]] }
    votings = Voting.select("id", "topic").by_session(s).non_registration.ordered.to_a

    stenograph = "<div class='links'>"
    stenograph += votings.map { |v, idx|
      link_to v.topic, "#voting-" + v.id.to_s
    }.join("<br>")
    stenograph += "</div><pre>"
    stenograph += s.stenograph

    stenograph.gsub! "\r\n", "<br>"

    members.each do |m|
      stenograph.gsub! m[1], "<a href='/members/#{m[0]}'>#{m[1]}</a>"
    end

    regex = /Гласували \d+ народни представители: за (\d+|няма), против (\d+,|няма,|и) (въздържали се|въздържал се) (\d+|няма|– няма)\./

    regex_enum = stenograph.gsub! regex

    regex_enum.each_with_index do |match, idx|
      options = {
       data: { voting: idx },
       class: ["btn", "btn-default", "show-voting"],
       id: "voting-" + votings[idx].id.to_s
      }
      output = button_tag options do
        match
      end
      output += "<br><div id='content-#{idx}'></div>".html_safe
    end
    stenograph + "</pre>"
  end

  def calendar year, &block
    year = (year.beginning_of_year..year.end_of_year).map { |d| Date.new(d.year, d.month, 1) }.uniq.in_groups_of(4)
    content_tag :table, class: "table table-bordered" do
      year.map do |quarter|
        content_tag :tr do
          quarter.map do |month|
            content_tag :td do
              self.capture(month, &block)
{'fraction_non_alphanumeric': 0.1716441370638164, 'fraction_numerical': 0.004086765168186105, 'mean_word_length': 2.756788665879575, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '234331', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1177, 'n_words': 260}