helper.rb 704 B

12345678910111213141516171819202122232425262728293031
  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. # log
  11. def log(message)
  12. thread_no = Thread.current[:thread_no] || '-'
  13. Rails.logger.info "thread##{thread_no}: #{message}"
  14. end
  15. # utf8 convert
  16. def utf8_encode(data)
  17. data.each { |key, value|
  18. next if !value
  19. next if value.class != String
  20. data[key] = Encode.conv('utf8', value)
  21. }
  22. end
  23. def reset_primary_key_sequence(table)
  24. DbHelper.import_post(table)
  25. end
  26. end
  27. end