<commit_before>require 'active_record'
require_relative '../visualization/stats'

class Carto::Visualization < ActiveRecord::Base
  include CacheHelper

  AUTH_DIGEST = '1211b3e77138f6e1724721f1ab740c9c70e66ba6fec5e989bb6640c4541ed15d06dbd5fdcbd3052b'

  TYPE_CANONICAL = 'table'
  TYPE_DERIVED = 'derived'
  TYPE_SLIDE = 'slide'
  TYPE_REMOTE = 'remote'

  KIND_GEOM   = 'geom'
  KIND_RASTER = 'raster'

  PRIVACY_PUBLIC = 'public'
  PRIVACY_PRIVATE = 'private'
  PRIVACY_LINK = 'link'
  PRIVACY_PROTECTED = 'password'

  # INFO: disable ActiveRecord inheritance column
  self.inheritance_column = :_type

  belongs_to :user, inverse_of: :visualizations, select: Carto::User::DEFAULT_SELECT
  belongs_to :full_user, class_name: Carto::User, foreign_key: :user_id, primary_key: :id, inverse_of: :visualizations, readonly: true

  belongs_to :user_table, class_name: Carto::UserTable, primary_key: :map_id, foreign_key: :map_id, inverse_of: :visualization

  has_one :permission, inverse_of: :entity, conditions: {:entity_type => 'vis'}, foreign_key: :entity_id

  has_many :likes, foreign_key: :subject
  has_many :shared_entities, foreign_key: :entity_id, inverse_of: :visualization

  # TODO: duplicated with user_table?
  belongs_to :table, class_name: Carto::UserTable, primary_key: :map_id, foreign_key: :map_id
  has_one :external_source
  has_many :unordered_children, class_name: Carto::Visualization, foreign_key: :parent_id

  has_many :overlays

  belongs_to :parent, class_name: Carto::Visualization, primary_key: :parent_id

  belongs_to :map

  has_many :related_templates, class_name: Carto::Template, foreign_key: :source_visualization_id

  has_one :synchronization, class_name: Carto::Synchronization

  def ==(other_visualization)
    self.id == other_visualization.id
  end
<commit_msg>Use Ruby 1.9 hash syntax<commit_after>require 'active_record'
require_relative '../visualization/stats'

class Carto::Visualization < ActiveRecord::Base
  include CacheHelper

  AUTH_DIGEST = '1211b3e77138f6e1724721f1ab740c9c70e66ba6fec5e989bb6640c4541ed15d06dbd5fdcbd3052b'

  TYPE_CANONICAL = 'table'
  TYPE_DERIVED = 'derived'
  TYPE_SLIDE = 'slide'
  TYPE_REMOTE = 'remote'

  KIND_GEOM   = 'geom'
  KIND_RASTER = 'raster'

  PRIVACY_PUBLIC = 'public'
  PRIVACY_PRIVATE = 'private'
  PRIVACY_LINK = 'link'
  PRIVACY_PROTECTED = 'password'

  # INFO: disable ActiveRecord inheritance column
  self.inheritance_column = :_type

  belongs_to :user, inverse_of: :visualizations, select: Carto::User::DEFAULT_SELECT
  belongs_to :full_user, class_name: Carto::User, foreign_key: :user_id, primary_key: :id, inverse_of: :visualizations, readonly: true

  belongs_to :user_table, class_name: Carto::UserTable, primary_key: :map_id, foreign_key: :map_id, inverse_of: :visualization

  has_one :permission, inverse_of: :entity, conditions: {entity_type: 'vis'}, foreign_key: :entity_id

  has_many :likes, foreign_key: :subject
  has_many :shared_entities, foreign_key: :entity_id, inverse_of: :visualization

  # TODO: duplicated with user_table?
  belongs_to :table, class_name: Carto::UserTable, primary_key: :map_id, foreign_key: :map_id
  has_one :external_source
  has_many :unordered_children, class_name: Carto::Visualization, foreign_key: :parent_id

  has_many :overlays

  belongs_to :parent, class_name: Carto::Visualization, primary_key: :parent_id

  belongs_to :map

  has_many :related_templates, class_name: Carto::Template, foreign_key: :source_visualization_id

  has_one :synchronization, class_name: Carto::Synchronization

  def ==(other_visualization)
    self.id == other_visualization.id
  end

{'fraction_non_alphanumeric': 0.09640883977900552, 'fraction_numerical': 0.027624309392265192, 'mean_word_length': 6.496894409937888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '1189971', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1288, 'n_words': 264}