helper.rb 904 B

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