<commit_before>require 'json'
require 'gooddata'

require 'fastercsv'
require 'fileutils'

%w(settings helper persistent userhelper).each {|a| require "#{a}"}
%w(project etl user).each {|a| require "data/#{a}"}

module PowerByHelper

  class Pwb

    def initialize(config_file,test_mode)
      @@test_mode = test_mode || false
      File.open( config_file, "r" ) do |f|
        json = JSON.load( f )
        Settings.load(json)
      end
    end


    def gooddata_login
      login = Settings.connection["login"]
      password = Settings.connection["password"]
      server = Settings.connection_server
      fail "Please put Gooddata Login and Password into the config file" if Helper.blank?(login) or Helper.blank?(password)
      GoodData.logger = @@log
      GoodData.connect(login,password,server,{:webdav_server => Settings.connection_webdav})
    end

    def init_persistent_storage
      @projects = Project.new() if (!Settings.deployment_project.nil? and !Settings.deployment_project.empty?)
      @etl = Etl.new() if (!Settings.deployment_etl.nil? and !Settings.deployment_etl.empty?)
    end

    def init_user_storage
      @user = User.new() if (!Settings.deployment_user.nil? and !Settings.deployment_user.empty?)
    end



    def project_provisioning
      @@log.info "Project persistent storage not initialized - skipping project provisioning" if @projects.nil?
      #Helper.retryable do
        @projects.create_projects
        @projects.handle_projects_disable
      #end
    end

    def etl_provisioning
      @@log.info "Etl persistent storage not initialized - skipping etl provisioning" if @etl.nil?
      #Helper.retryable do
      if (!@etl.nil?)
        @etl.deploy_process
        @etl.create_schedules
        @etl.create_notifications
      end
    end

    def user_synchronization
      #@@log.info "Users persistent storage not initialized - skipping user provisioning" if @user.nil?
      #Helper.retryable do
      init_user_storage
      if (!@user.nil?)
        @user.create_new_users
        @user.invite_users
        @user.add_users
        @user.disable_users
        @user.update_users
      end
      #end
    end


    def update_schedules()
      @@log.info "Starting schedule update"
      Persistent.reset_schedule_update
      Helper.retryable do
        @etl.update_schedules
      end
    end





    def delete_all_projects(force)
      @@log.info "Deleting project - dry run (to normal run specify force parameter)" if !force
      Persistent.project_data.each do |project|
        if (!project.nil? and !project.project_pid.nil?)
          @@log.info "Deleting project #{project.project_pid} #{ force ? "FORCED" : "DRY RUN"}"
          project_gd = GoodData::Project[project.project_pid]
          if force
            project_gd.delete if force
            Persistent.delete_user_project_by_project_pid(project.project_pid)
            Persistent.delete_etl_by_project_pid(project.project_pid)
            Persistent.delete_project_by_project_pid(project.project_pid)
          end
        end
      end
    end







  end


end<commit_msg>Fixed project deletion problem with storage synchronization<commit_after>require 'json'
require 'gooddata'

require 'fastercsv'
require 'fileutils'

%w(settings helper persistent userhelper).each {|a| require "#{a}"}
%w(project etl user).each {|a| require "data/#{a}"}

module PowerByHelper

  class Pwb

    def initialize(config_file,test_mode)
      @@test_mode = test_mode || false
      File.open( config_file, "r" ) do |f|
        json = JSON.load( f )
        Settings.load(json)
      end
    end


    def gooddata_login
      login = Settings.connection["login"]
      password = Settings.connection["password"]
      server = Settings.connection_server
      fail "Please put Gooddata Login and Password into the config file" if Helper.blank?(login) or Helper.blank?(password)
      GoodData.logger = @@log
      GoodData.connect(login,password,server,{:webdav_server => Settings.connection_webdav})
    end

    def init_persistent_storage
      @projects = Project.new() if (!Settings.deployment_project.nil? and !Settings.deployment_project.empty?)
      @etl = Etl.new() if (!Settings.deployment_etl.nil? and !Settings.deployment_etl.empty?)
    end

    def init_user_storage
      @user = User.new() if (!Settings.deployment_user.nil? and !Settings.deployment_user.empty?)
    end



    def project_provisioning
      @@log.info "Project persistent storage not initialized - skipping project provisioning" if @projects.nil?
      #Helper.retryable do
        @projects.create_projects
        @projects.handle_projects_disable
      #end
    end

    def etl_provisioning
      @@log.info "Etl persistent storage not initialized - skipping etl provisioning" if @etl.nil?
      #Helper.retryable do
      if (!@etl.nil?)
        @etl.deploy_process
        @etl.create_schedules
        @etl.create_notifications
      end
    end

    def user_synchronization
      #@@log.info "Users persistent storage not initialized - skipping user provisioning" if @user.nil?
      #Helper.retryable do
      init_user_storage
      if (!@user.nil?)
        @user.create_new_users
        @user.invite_users
        @user.add_users
        @user.disable_users
        @user.update_users
      end
      #end
    end


    def update_schedules()
      @@log.info "Starting schedule update"
      Persistent.reset_schedule_update
      Helper.retryable do
        @etl.update_schedules
      end
    end





    def delete_all_projects(force)
      @@log.info "Deleting project - dry run (to normal run specify force parameter)" if !force
      Persistent.project_data.each do |project|
        if (!project.nil? and !project.project_pid.nil?)
          @@log.info "Deleting project #{project.project_pid} #{ force ? "FORCED" : "DRY RUN"}"
          project_gd = GoodData::Project[project.project_pid]
          if force
            project_gd.delete if force
            Persistent.delete_user_project_by_project_pid(project.project_pid)
            Persistent.delete_etl_by_project_pid(project.project_pid)
            Persistent.delete_project_by_project_pid(project.project_pid)
          end
        end
      end
      Persistent.store_project
      Persistent.store_etl
      Persistent.store_user_project
    end







  end


end
{'fraction_non_alphanumeric': 0.09057971014492754, 'fraction_numerical': 0.0, 'mean_word_length': 2.8086382723455308, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3269839', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1867, 'n_words': 444}