<commit_before>class RedmineInstance
  attr_accessor :name, :server, :version, :size, :admin,
                :nb_projects, :nb_users

  def self.all
    return @instances if defined?(@instances)
    @instances = []
    files.each do |f|
      begin
        json = JSON.parse(f)
        json.each do |server, components|
          instances = components["redmine"]
          instances.each do |hsh|
            @instances << new(hsh.merge("server"=>server))
          end
        end
      rescue JSON::ParserError
        Rails.logger.error "Error parsing a JSON file for Redmine"
      end
    end
    @instances
  end

  def self.files
    Dir.glob(dir+"/*").map{|f| File.read(f) if File.file?(f)}.compact
   end

  def self.dir
    Rails.root.join("data/redmine").to_s
  end

  def initialize(hsh)
    @name = hsh["name"]
    @server = hsh["server"]
    @version = hsh["version"]
    @size = hsh["size"].to_i
    @admin = hsh["admin"]
    @nb_projects = hsh["nb_projects"].to_i<commit_msg>Do not cache RedmineInstance.all (causes problems in production mode)<commit_after>class RedmineInstance
  attr_accessor :name, :server, :version, :size, :admin,
                :nb_projects, :nb_users

  def self.all
    instances = []
    files.each do |f|
      begin
        json = JSON.parse(f)
        json.each do |server, components|
          instances = components["redmine"]
          instances.each do |hsh|
            instances << new(hsh.merge("server"=>server))
          end
        end
      rescue JSON::ParserError
        Rails.logger.error "Error parsing a JSON file for Redmine"
      end
    end
    instances
  end

  def self.files
    Dir.glob(dir+"/*").map{|f| File.read(f) if File.file?(f)}.compact
   end

  def self.dir
    Rails.root.join("data/redmine").to_s
  end

  def initialize(hsh)
    @name = hsh["name"]
    @server = hsh["server"]
    @version = hsh["version"]
    @size = hsh["size"].to_i
    @admin = hsh["admin"]
    @nb_projects = hsh["nb_projects"].to_i
{'fraction_non_alphanumeric': 0.13296537882589063, 'fraction_numerical': 0.0, 'mean_word_length': 2.449826989619377, 'pattern_counts': {'":': 0, '<': 7, '<?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': '945539', 'n_tokens_mistral': 667, 'n_tokens_neox': 660, 'n_words': 153}