<commit_before>module Carto
  module Api
    class ImportsController < ::Api::ApplicationController

      ssl_required :index, :show
      ssl_allowed :service_token_valid?

      def index
        imports = DataImportsService.new.process_recent_user_imports(current_user)
        render json: { imports: imports.map(&:id), success: true }
      end

      def show
        import = DataImportsService.new.process_by_id(params[:id])
        render_404 and return if import.nil?

        data = import.api_public_values
        if import.state == Carto::DataImport::STATE_COMPLETE
          data[:any_table_raster] = import.is_raster?

          decorate_twitter_import_data!(data, import)
          decorate_default_visualization_data!(data, import)
        end

        render json: data
      end

      def service_token_valid?
        valid = DataImportsService.new.validate_synchronization_oauth(logged_user, params[:id])
        render_jsonp({ oauth_valid: valid, success: true })
      rescue => e
        CartoDB.notify_exception(e)
        render_jsonp({ errors: e.message }, 400)
      end

      def list_files_for_service
        filter = params[:filter].present? ? params[:filter] : []<commit_msg>list_files_for_service requires ssl suppport<commit_after>module Carto
  module Api
    class ImportsController < ::Api::ApplicationController

      ssl_required :index, :show
      ssl_allowed :service_token_valid?, :list_files_for_service

      def index
        imports = DataImportsService.new.process_recent_user_imports(current_user)
        render json: { imports: imports.map(&:id), success: true }
      end

      def show
        import = DataImportsService.new.process_by_id(params[:id])
        render_404 and return if import.nil?

        data = import.api_public_values
        if import.state == Carto::DataImport::STATE_COMPLETE
          data[:any_table_raster] = import.is_raster?

          decorate_twitter_import_data!(data, import)
          decorate_default_visualization_data!(data, import)
        end

        render json: data
      end

      def service_token_valid?
        valid = DataImportsService.new.validate_synchronization_oauth(logged_user, params[:id])
        render_jsonp({ oauth_valid: valid, success: true })
      rescue => e
        CartoDB.notify_exception(e)
        render_jsonp({ errors: e.message }, 400)
      end

      def list_files_for_service
        filter = params[:filter].present? ? params[:filter] : []
{'fraction_non_alphanumeric': 0.08555286521388217, 'fraction_numerical': 0.004842615012106538, 'mean_word_length': 2.9919484702093397, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6807726', 'n_tokens_mistral': 742, 'n_tokens_neox': 715, 'n_words': 146}