Class: Translations::ExportRestaurantsTranslationWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- Translations::ExportRestaurantsTranslationWorker
- Includes:
- ElasticAPM::SpanHelpers
- Defined in:
- app/workers/translations/export_restaurants_translation_worker.rb
Overview
Worker to export restaurant translations into an Excel file with AWS pre-filled translations. Queue: longprocess for large datasets with external API calls, or default for smaller exports.
Constant Summary collapse
- EXPORT_COLUMNS =
%w[id existing_locale field original_text target_locale translated_text].freeze
- TRANSLATABLE_FIELDS =
%i[name short_name custom_text address misc food_details ambience self_pickup_message].freeze
Instance Method Summary collapse
-
#perform(target_locale, user_id) ⇒ Object
Mirrors lifecycle used in NotificationWorkers::ReservationReport Creates an Attachment record, updates status, stores download_link json, then queues mail.
Methods inherited from ApplicationWorker
Instance Method Details
#perform(target_locale, user_id) ⇒ Object
Mirrors lifecycle used in NotificationWorkers::ReservationReport Creates an Attachment record, updates status, stores download_link json, then queues mail.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/workers/translations/export_restaurants_translation_worker.rb', line 21 def perform(target_locale, user_id) @started_at = Time.current @target_locale = target_locale.to_sym @user = User.find_by(id: user_id) return unless @user raise ArgumentError, 'Target locale cannot be English; choose a non-English language.' if @target_locale == :en if defined?(BUSINESS_LOGGER) BUSINESS_LOGGER.set_business_context({ worker_class: self.class.name, user_id: @user.id, target_locale: @target_locale }) end BUSINESS_LOGGER.info('translation_export_start') if defined?(BUSINESS_LOGGER) # Force base locale context for reading source strings without leaking global thread locale. I18n.with_locale(:en) do execute_export end end |