<commit_before>class HomesController < ApplicationController
  def update_install
    if is_master_instance?
      flash[:error] = "You can't update yourself, as you already are on Master Instance"
      redirect_to "/about"
    else
      #begin

        #"git remote show origin"   "git config --get remote.origin.url"
        #git log -1 --format="%cd"      #To obtain date and time of the last commit in a current branch one
        #git log --name-status HEAD^..HEAD
        # git show --summary
        # git show --stat
       #git log -1 --stat

      external_last_schemas_version = ExternalMasterDatabase::ExternalSchemaMigration.all.last
        version = nil
        #To get all version : ActiveRecord::Migrator.get_all_versions
        local_last_schema_version = ActiveRecord::Migrator.current_version  #current local migration version

        if local_last_schema_version.to_i == external_last_schemas_version.version.to_i
          Home::update_master_data!
          $latest_update = Time.now
          flash[:notice] = "Projestimate data have been updated successfully."
          redirect_to "/about" and return
        else
          flash[:error] = "Your local DB schema differ to the MasterData one, please check for modifications or run 'rake db:migrate' command "
          redirect_to "/about" and return
        end

      #rescue Errno::ECONNREFUSED
      #  flash[:error] = "!!! WARNING - Error: Default data was not loaded, please investigate. Maybe run bundle exec rake sunspot:solr:start RAILS_ENV=your_environnement"
      #  redirect_to "/about" and return
      #rescue Exception<commit_msg>Loading and/or Updating Master data must check db-schema version : refs #331<commit_after>class HomesController < ApplicationController
  def update_install
    if is_master_instance?
      flash[:error] = "You can't update yourself, as you already are on Master Instance"
      redirect_to "/about"
    else
      #begin

        #"git remote show origin"   "git config --get remote.origin.url"
        #git log -1 --format="%cd"      #To obtain date and time of the last commit in a current branch one
        #git log --name-status HEAD^..HEAD
        # git show --summary
        # git show --stat
       #git log -1 --stat

        external_last_schemas_version = ExternalMasterDatabase::ExternalSchemaMigration.all.last
        version = nil
        #To get all version : ActiveRecord::Migrator.get_all_versions
        local_last_schema_version = ActiveRecord::Migrator.current_version  #current local migration version

        if local_last_schema_version.to_i == external_last_schemas_version.version.to_i
          #Check if pull is needed
          ##need_to_pull = "git pull --dry-run" ## "git pull --dry-run | grep -q -v 'Already up-to-date.' && changed=1"

          Home::update_master_data!
          $latest_update = Time.now
          flash[:notice] = "Projestimate data have been updated successfully."
          redirect_to "/about" and return
        else
          flash[:error] = "Your local DB schema differ to the MasterData one, please check for modifications or run 'rake db:migrate' command "
          redirect_to "/about" and return
        end

      #rescue Errno::ECONNREFUSED
      #  flash[:error] = "!!! WARNING - Error: Default data was not loaded, please investigate. Maybe run bundle exec rake sunspot:solr:start RAILS_ENV=your_environnement"
      #  redirect_to "/about" and return
      #rescue Exception
{'fraction_non_alphanumeric': 0.08206161819752375, 'fraction_numerical': 0.002303484019579614, 'mean_word_length': 2.7925764192139737, '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': '7301566', 'n_tokens_mistral': 958, 'n_tokens_neox': 936, 'n_words': 317}