<commit_before>
class NilClass
  def method_missing(name, *args, &block)
  end
end

class Sequel::Model
  #def validates_url_format(input)
  #end
  #def validates_config_syntax(input)
  #end
end

class Graph < Sequel::Model

  many_to_many :dashboards
  
  plugin :boolean_readers
  plugin :prepared_statements
  plugin :prepared_statements_safe
  plugin :validation_helpers

  def before_create
    super
    self.enabled = true
    self.created_at = Time.now
    self.updated_at = Time.now
  end

  def before_update
    super
    self.updated_at = Time.now
  end

  def validate
    super
    validates_presence :uuid
    validates_presence :name
    validates_presence :url
    #validates_url_format self.url
    #validates_config_syntax self.configuration
  end

  def destroy
    self.enabled = false
    self.save
  end

  def destroy!
    self.delete
  end

  def restore
    self.enabled = true
    self.save
  end
end
<commit_msg>parse url into configuration blob<commit_after>require 'cgi'
require 'uri'
require 'json'

class NilClass
  def method_missing(name, *args, &block)
  end
end

class Sequel::Model
  #def validates_url_format(input)
  #end
  #def validates_config_syntax(input)
  #end
end

class Graph < Sequel::Model

  many_to_many :dashboards
  
  plugin :boolean_readers
  plugin :prepared_statements
  plugin :prepared_statements_safe
  plugin :validation_helpers

  def before_create
    super
    self.configuration = deconstruct(self.url)
    self.enabled = true
    self.created_at = Time.now
    self.updated_at = Time.now
  end

  def deconstruct(url)
    CGI.parse(URI.parse(url).query).to_json
  end

  def before_update
    super
    self.updated_at = Time.now
  end

  def validate
    super
    validates_presence :uuid
    validates_presence :name
    validates_presence :url
    #validates_url_format self.url
    #validates_config_syntax self.configuration
  end

  def destroy
    self.enabled = false
    self.save
  end

  def destroy!
    self.delete
  end

  def restore
    self.enabled = true
    self.save
  end
end

{'fraction_non_alphanumeric': 0.06153100775193798, 'fraction_numerical': 0.0, 'mean_word_length': 3.240246406570842, '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': '6413689', 'n_tokens_mistral': 704, 'n_tokens_neox': 675, 'n_words': 171}