<commit_before># frozen_string_literal: true
module Meshchat
  class Node < ActiveRecord::Base
    IPV4_WITH_PORT = /((?:(?:^|\.)(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])){4})(:\d*)?/
    # http://rubular.com/r/WYT09ptct3
    DOMAIN_WITH_PORT = /(https?:\/\/)?([\da-z\.-]+)\.?([a-z\.]{2,6})([\/\w \.-]*)*[^\/](:\d*)?/

    validates :alias_name,
      :location,
      :public_key, presence: true

    validates :uid, presence: true, uniqueness: true

    # ipv4 with port
    validates_format_of :location, with: lambda { |e|
      location = e.location || ''
      location.include?('//') || location.include?('localhost') ?
        DOMAIN_WITH_PORT :
        IPV4_WITH_PORT
    }

    scope :on_local_network, -> { where(on_local_network: true) }
    scope :on_relay, -> { where(on_relay: true) }
    scope :online, -> { on_local_network.or(on_relay) }<commit_msg>disable existing validation on compound property location<commit_after># frozen_string_literal: true
module Meshchat
  class Node < ActiveRecord::Base
    IPV4_WITH_PORT = /((?:(?:^|\.)(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])){4})(:\d*)?/
    # http://rubular.com/r/WYT09ptct3
    DOMAIN_WITH_PORT = /(https?:\/\/)?([\da-z\.-]+)\.?([a-z\.]{2,6})([\/\w \.-]*)*[^\/](:\d*)?/

    validates :alias_name,
      :public_key, presence: true

    validates :uid, presence: true, uniqueness: true

    # ipv4 with port
    # validates_format_of :location, with: lambda { |e|
    #   location = e.location || ''
    #   location.include?('//') || location.include?('localhost') ?
    #     DOMAIN_WITH_PORT :
    #     IPV4_WITH_PORT
    # }

    scope :on_local_network, -> { where(on_local_network: true) }
    scope :on_relay, -> { where(on_relay: true) }
    scope :online, -> { on_local_network.or(on_relay) }
{'fraction_non_alphanumeric': 0.21958121109224674, 'fraction_numerical': 0.022637238256932653, 'mean_word_length': 3.0925925925925926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2459507', 'n_tokens_mistral': 708, 'n_tokens_neox': 679, 'n_words': 107}