helper.rb 822 B

12345678910111213141516171819202122232425262728293031323334
  1. module Import
  2. module Helper
  3. # rubocop:disable Style/ModuleFunction
  4. extend self
  5. def check_import_mode
  6. # check if system is in import mode
  7. return true if Setting.get('import_mode')
  8. raise 'System is not in import mode!'
  9. end
  10. def check_system_init_done
  11. return true if !Setting.get('system_init_done')
  12. raise 'System is already system_init_done!'
  13. end
  14. def log(message)
  15. thread_no = Thread.current[:thread_no] || '-'
  16. Rails.logger.info "thread##{thread_no}: #{message}"
  17. end
  18. def utf8_encode(data)
  19. data.each do |key, value|
  20. next if !value
  21. next if value.class != String
  22. data[key] = Encode.conv('utf8', value)
  23. end
  24. end
  25. def reset_primary_key_sequence(table)
  26. DbHelper.import_post(table)
  27. end
  28. end
  29. end