helper.rb 827 B

12345678910111213141516171819202122232425262728293031323334353637
  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.respond_to?(:utf8_encode)
  22. data[key] = value.utf8_encode
  23. end
  24. end
  25. def reset_primary_key_sequence(table)
  26. DbHelper.import_post(table)
  27. end
  28. end
  29. end