<commit_before>class ActionPlanReportGenerator < ActionView::Base
  include ApplicationHelper
  include Rails.application.routes.url_helpers

  def initialize
    super(ActionController::Base.view_paths, {})
  end

  def report
    files = {}

    files["pam"] = render(
      file: 'revision/action_plan_reports/report.html.erb',
      locals: {action_plans: city_action_plans, title: "PAM"}
    )

    District.all.each do |district|
      files["pad-#{district.id}"] = render(
        file: 'revision/action_plan_reports/report.html.erb',
        locals: {
          action_plans: district_action_plans(district),
          title: "PAD #{district.name}"
        }
      )
    end

    files
  end

  def categories
    Category.includes(:subcategories)
  end

  def city_action_plans
    scope.where(scope: 'city')
  end

  def district_action_plans(district)
    scope.where(scope: 'district', district: district.id)
  end

  def from_subcategory(action_plans, district)
    decorate(
      action_plans.where(subcategory_id: district.id)
    )
  end

  private

  def scope
    @scope ||= ActionPlan.order('weight desc').includes(:proposals)
  end<commit_msg>Fix exporter weight<commit_after>class ActionPlanReportGenerator < ActionView::Base
  include ApplicationHelper
  include Rails.application.routes.url_helpers

  def initialize
    super(ActionController::Base.view_paths, {})
  end

  def report
    files = {}

    files["pam"] = render(
      file: 'revision/action_plan_reports/report.html.erb',
      locals: {action_plans: city_action_plans, title: "PAM"}
    )

    District.all.each do |district|
      files["pad-#{district.id}"] = render(
        file: 'revision/action_plan_reports/report.html.erb',
        locals: {
          action_plans: district_action_plans(district),
          title: "PAD #{district.name}"
        }
      )
    end

    files
  end

  def categories
    Category.includes(:subcategories)
  end

  def city_action_plans
    scope.where(scope: 'city')
  end

  def district_action_plans(district)
    scope.where(scope: 'district', district: district.id)
  end

  def from_subcategory(action_plans, district)
    decorate(
      action_plans.where(subcategory_id: district.id)
    )
  end

  private

  def scope
    @scope ||= ActionPlan.order('weight asc').includes(:proposals)
  end
{'fraction_non_alphanumeric': 0.10715816545220745, 'fraction_numerical': 0.0, 'mean_word_length': 3.2054054054054055, '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': '1205146', 'n_tokens_mistral': 768, 'n_tokens_neox': 737, 'n_words': 139}