<commit_before>require 'active_record'

class Carto::Map < ActiveRecord::Base

  has_and_belongs_to_many :layers, class_name: 'Carto::Layer', order: '"order"'

  has_and_belongs_to_many :base_layers, class_name: 'Carto::Layer', order: '"order"'

  has_and_belongs_to_many :data_layers, class_name: 'Carto::Layer', 
    conditions: { kind: 'carto' }, order: '"order"'
    
  has_and_belongs_to_many :user_layers, class_name: 'Carto::Layer', 
    conditions: { kind: ['tiled', 'background', 'gmapsbase', 'wms'] }, order: '"order"'

  has_and_belongs_to_many :carto_and_torque_layers, class_name: 'Carto::Layer', 
    conditions: { kind: ['carto', 'torque'] }, order: '"order"'

  has_and_belongs_to_many :torque_layers, class_name: 'Carto::Layer',
    conditions: { kind: 'torque' }, order: '"order"'

  has_and_belongs_to_many :other_layers, class_name: 'Carto::Layer', 
    conditions: "kind not in ('carto', 'tiled', 'background', 'gmapsbase', 'wms')", order: '"order"'

  belongs_to :user

  has_many :tables, class_name: Carto::UserTable

  def viz_updated_at
    get_the_last_time_tiles_have_changed_to_render_it_in_vizjsons
  end

  def provider
    # TODO: right now only provider
    'leaflet'
  end

  def self.provider_for_baselayer(layer)
    layer[:kind] == 'tiled' ? 'leaflet': 'googlemaps'<commit_msg>enable provider in Map model<commit_after>require 'active_record'

class Carto::Map < ActiveRecord::Base

  has_and_belongs_to_many :layers, class_name: 'Carto::Layer', order: '"order"'

  has_and_belongs_to_many :base_layers, class_name: 'Carto::Layer', order: '"order"'

  has_and_belongs_to_many :data_layers, class_name: 'Carto::Layer', 
    conditions: { kind: 'carto' }, order: '"order"'
    
  has_and_belongs_to_many :user_layers, class_name: 'Carto::Layer', 
    conditions: { kind: ['tiled', 'background', 'gmapsbase', 'wms'] }, order: '"order"'

  has_and_belongs_to_many :carto_and_torque_layers, class_name: 'Carto::Layer', 
    conditions: { kind: ['carto', 'torque'] }, order: '"order"'

  has_and_belongs_to_many :torque_layers, class_name: 'Carto::Layer',
    conditions: { kind: 'torque' }, order: '"order"'

  has_and_belongs_to_many :other_layers, class_name: 'Carto::Layer', 
    conditions: "kind not in ('carto', 'tiled', 'background', 'gmapsbase', 'wms')", order: '"order"'

  belongs_to :user

  has_many :tables, class_name: Carto::UserTable

  def viz_updated_at
    get_the_last_time_tiles_have_changed_to_render_it_in_vizjsons
  end

  def self.provider_for_baselayer(layer)
    layer[:kind] == 'tiled' ? 'leaflet': 'googlemaps'
{'fraction_non_alphanumeric': 0.147024504084014, 'fraction_numerical': 0.0, 'mean_word_length': 5.951351351351351, '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': '734971', 'n_tokens_mistral': 970, 'n_tokens_neox': 926, 'n_words': 188}