From afe46d3570a62f11a441d6e558fddfe4df2c67ab Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 19 Jan 2016 07:58:58 +0100 Subject: [PATCH] Prepared for postgresql. --- app/controllers/calendars_controller.rb | 2 +- app/controllers/slas_controller.rb | 4 ++-- app/models/channel/filter/database.rb | 2 +- app/models/locale.rb | 2 +- app/models/ticket/escalation.rb | 2 +- app/models/translation.rb | 2 +- lib/core_ext/string.rb | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 778bb5586..7ecc83614 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -10,7 +10,7 @@ class CalendarsController < ApplicationController # calendars calendar_ids = [] - Calendar.all.order(:name).each {|calendar| + Calendar.all.order(:name, :created_at).each {|calendar| calendar_ids.push calendar.id assets = calendar.assets(assets) } diff --git a/app/controllers/slas_controller.rb b/app/controllers/slas_controller.rb index a26c37d3c..d94c6c447 100644 --- a/app/controllers/slas_controller.rb +++ b/app/controllers/slas_controller.rb @@ -53,7 +53,7 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password} # calendars calendar_ids = [] - Calendar.all.order(:name).each {|calendar| + Calendar.all.order(:name, :created_at).each {|calendar| calendar_ids.push calendar.id assets = calendar.assets(assets) } @@ -61,7 +61,7 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password} # slas sla_ids = [] models = Models.all - Sla.all.order(:name).each {|sla| + Sla.all.order(:name, :created_at).each {|sla| sla_ids.push sla.id assets = sla.assets(assets) diff --git a/app/models/channel/filter/database.rb b/app/models/channel/filter/database.rb index 02dff0b80..da66dd579 100644 --- a/app/models/channel/filter/database.rb +++ b/app/models/channel/filter/database.rb @@ -6,7 +6,7 @@ module Channel::Filter::Database def self.run( _channel, mail ) # process postmaster filter - filters = PostmasterFilter.where( active: true, channel: 'email' ).order(:name) + filters = PostmasterFilter.where( active: true, channel: 'email' ).order(:name, :created_at) filters.each {|filter| Rails.logger.info " proccess filter #{filter.name} ..." all_matches_ok = true diff --git a/app/models/locale.rb b/app/models/locale.rb index e295da923..4d9496c95 100644 --- a/app/models/locale.rb +++ b/app/models/locale.rb @@ -5,7 +5,7 @@ class Locale < ApplicationModel def self.to_sync locales = Locale.where(active: true) if Rails.env.test? - locales = Locale.where(active: true, locale: ['en-us', 'de-de']) + locales = Locale.where(active: true, locale: ['en-us']) end # read used locales based on env, e. g. export Z_LOCALES='en-us:de-de' diff --git a/app/models/ticket/escalation.rb b/app/models/ticket/escalation.rb index bb43f77f8..e34610f4c 100644 --- a/app/models/ticket/escalation.rb +++ b/app/models/ticket/escalation.rb @@ -207,7 +207,7 @@ returns sla_selected = nil sla_list = Cache.get('SLA::List::Active') if sla_list.nil? - sla_list = Sla.all.order(:name) + sla_list = Sla.all.order(:name, :created_at) Cache.write('SLA::List::Active', sla_list, { expires_in: 1.hour }) end sla_list.each {|sla| diff --git a/app/models/translation.rb b/app/models/translation.rb index 70b0b5b48..629891564 100644 --- a/app/models/translation.rb +++ b/app/models/translation.rb @@ -16,7 +16,7 @@ all: dedicated: - Translation.load(locale) # e. g. en-us or de-de + Translation.load(locale) # e. g. 'en-us' or 'de-de' =end diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index 01e3e4f22..aa01ccfd7 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -57,7 +57,7 @@ class String # unfortunaly UTF8mb4 will raise other limitaions of max varchar and lower index sizes # More details: http://pjambet.github.io/blog/emojis-and-mysql/ def utf8_to_3bytesutf8 - return if ActiveRecord::Base.connection_config[:adapter] != 'mysql2' + return self if ActiveRecord::Base.connection_config[:adapter] != 'mysql2' each_char.select {|c| if c.bytes.count > 3 Rails.logger.warn "strip out 4 bytes utf8 chars '#{c}' of '#{self}'"