Class: AppCommand::Fix
- Inherits:
-
Convoy::ActionCommand::Base
- Object
- Convoy::ActionCommand::Base
- AppCommand::Fix
- Defined in:
- lib/routes/fix.rb
Instance Method Summary collapse
-
#clear_sessions ⇒ Object
Fixes problem with Login (when sessions get screwed up).
- #execute ⇒ Object
- #opts_routing ⇒ Object
- #opts_validate ⇒ Object
-
#sql_updates ⇒ Object
Runs all SQL updates from a specified index.
Instance Method Details
#clear_sessions ⇒ Object
Fixes problem with Login (when sessions get screwed up)
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/routes/fix.rb', line 55 def clear_sessions App::Terminal::info('Attempting to clear all sessions from DB..') App::Terminal::output('DELETE FROM _session.session;') @mysql_ses.query('DELETE FROM session;') App::Terminal::output('DELETE FROM app.session_to_licence_type;') @mysql_app.query('DELETE FROM session_to_licence_type;') App::Terminal::output('DELETE FROM app.sessions;') @mysql_app.query('DELETE FROM sessions;') puts end |
#execute ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/routes/fix.rb', line 5 def execute @opts = @args = arguments @mysql_app = App::MySQL::vm @mysql_ses = App::MySQL::vm('_session') @sql_index_start = nil @sql_index_end = nil opts_validate opts_routing end |
#opts_routing ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/routes/fix.rb', line 41 def opts_routing if @opts[:login_sessions] clear_sessions elsif @opts[:sql_updates] sql_updates else system('bp f -h') end end |
#opts_validate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/routes/fix.rb', line 21 def opts_validate if @opts[:sql_updates] unless @args.any? App::Terminal::error('Must specify a SQL update to run from', "For example, if the #{App::Terminal::format_highlight('current update fail')} happened at #{App::Terminal::format_directory('0306.sql')}, type \xe2\x86\x92 #{App::Terminal::format_action('306')}", true) end if @args[0] =~ /\A0?\d{3}\z/i @sql_index_start = @args[0].to_i sql_files = App::UtilsFiles::get_files_in_dir("#{App::Config.param(ConfigUnique::WORKSTATION_PATH_TO_BP_DB)}/brightpearl/structure") @sql_index_end = File.basename(sql_files[sql_files.length - 1], '.sql').to_i if @sql_index_start > @sql_index_end App::Terminal::error("Invalid SQL update index: #{App::Terminal::format_invalid(@args[0])}", "The most recent SQL update is currently: #{App::Terminal::format_directory("0#{@sql_index_end}.sql")}", true) end else App::Terminal::error("Invalid SQL update index: #{App::Terminal::format_invalid(@args[0])}", "The SQL update index you supplied does not match the required format (IE: #{App::Terminal::format_highlight('306')} or #{App::Terminal::format_highlight('0306')}).", true) end end end |
#sql_updates ⇒ Object
Runs all SQL updates from a specified index
68 69 70 |
# File 'lib/routes/fix.rb', line 68 def sql_updates App::VM::run_on_vm('sql-updates.sh', [@sql_index_start, @sql_index_end + 1]) end |