<commit_before># encoding: utf-8

require_relative '../../services/carto/visualizations_export_service_2'

module Carto
  class Mapcap < ActiveRecord::Base
    include Carto::VisualizationsExportService2Exporter
    include Carto::VisualizationsExportService2Importer

    belongs_to :visualization, class_name: Carto::Visualization, foreign_key: 'vis_id'

    before_save :generate_export_vizjson

    def regenerate_visualization
      return unless export_vizjson

      restored_visualization = build_visualization_from_json_export(export_vizjson)

      restored_visualization.user_id = visualization.user.id

      restored_visualization
    end

    private<commit_msg>grab created_at/updated_at from visualization<commit_after># encoding: utf-8

require_relative '../../services/carto/visualizations_export_service_2'

module Carto
  class Mapcap < ActiveRecord::Base
    include Carto::VisualizationsExportService2Exporter
    include Carto::VisualizationsExportService2Importer

    belongs_to :visualization, class_name: Carto::Visualization, foreign_key: 'vis_id'

    before_save :generate_export_vizjson

    def regenerate_visualization
      return unless export_vizjson

      restored_visualization = build_visualization_from_json_export(export_vizjson)

      restored_visualization.created_at = visualization.created_at
      restored_visualization.updated_at = visualization.updated_at

      Carto::VisualizationsExportPersistenceService.new.apply_user(visualization.user, restored_visualization)
    end

    private
{'fraction_non_alphanumeric': 0.05912930474333983, 'fraction_numerical': 0.005198180636777128, 'mean_word_length': 5.390041493775934, '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': '7360032', 'n_tokens_mistral': 453, 'n_tokens_neox': 428, 'n_words': 73}