From 901addff6f75e0d93e406af4e56b7e3c4ef7a598 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 30 Jun 2015 15:35:16 +0200 Subject: [PATCH 01/15] Not longer needed. --- app/models/time_accounting.rb | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 app/models/time_accounting.rb diff --git a/app/models/time_accounting.rb b/app/models/time_accounting.rb deleted file mode 100644 index e40d4fa57..000000000 --- a/app/models/time_accounting.rb +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ - -class TimeAccounting < ActiveRecord::Base -end From 7bc55193ce7d1d55438ca5a20b841d7e1d81bd7f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 30 Jun 2015 15:36:04 +0200 Subject: [PATCH 02/15] Updated doc. --- app/models/ticket/search.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/ticket/search.rb b/app/models/ticket/search.rb index 138406051..db14243ac 100644 --- a/app/models/ticket/search.rb +++ b/app/models/ticket/search.rb @@ -7,9 +7,9 @@ module Ticket::Search search tickets via search index result = Ticket.search( - :current_user => User.find(123), - :query => 'search something', - :limit => 15, + current_user: User.find(123), + query: 'search something', + limit: 15, ) returns @@ -19,10 +19,10 @@ returns search tickets via search index result = Ticket.search( - :current_user => User.find(123), - :query => 'search something', - :limit => 15, - :full => false, + current_user: User.find(123), + query: 'search something', + limit: 15, + full: false, ) returns @@ -32,8 +32,8 @@ returns search tickets via database result = Ticket.search( - :current_user => User.find(123), - :condition => { + current_user: User.find(123), + condition: { 'tickets.owner_id' => user.id, 'tickets.state_id' => Ticket::State.where( state_type_id: Ticket::StateType.where( @@ -44,8 +44,8 @@ search tickets via database ), ), }, - :limit => 15, - :full => false, + limit: 15, + full: false, ) returns From c54dace898158e2764b04a06f328e6c104fcc4d8 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 30 Jun 2015 16:44:23 +0200 Subject: [PATCH 03/15] Merged files. --- db/migrate/20120101000001_create_base.rb | 7 +++++++ db/migrate/20150616224717_add_base_indexes.rb | 12 ------------ 2 files changed, 7 insertions(+), 12 deletions(-) delete mode 100644 db/migrate/20150616224717_add_base_indexes.rb diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 99427194b..2bc455343 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -41,6 +41,7 @@ class CreateBase < ActiveRecord::Migration add_index :users, [:login], unique: true add_index :users, [:email] #add_index :users, [:email], unique: => true + add_index :users, [:organization_id] add_index :users, [:image] add_index :users, [:department] add_index :users, [:phone] @@ -111,16 +112,22 @@ class CreateBase < ActiveRecord::Migration t.integer :user_id t.integer :role_id end + add_index :roles_users, [:user_id] + add_index :roles_users, [:role_id] create_table :groups_users, id: false do |t| t.integer :user_id t.integer :group_id end + add_index :groups_users, [:user_id] + add_index :groups_users, [:group_id] create_table :organizations_users, id: false do |t| t.integer :user_id t.integer :organization_id end + add_index :organizations_users, [:user_id] + add_index :organizations_users, [:organization_id] create_table :authorizations do |t| t.string :provider, limit: 250, null: false diff --git a/db/migrate/20150616224717_add_base_indexes.rb b/db/migrate/20150616224717_add_base_indexes.rb deleted file mode 100644 index 2727009d0..000000000 --- a/db/migrate/20150616224717_add_base_indexes.rb +++ /dev/null @@ -1,12 +0,0 @@ -class AddBaseIndexes < ActiveRecord::Migration - def change - add_index :users, [:organization_id] - add_index :roles_users, [:user_id] - add_index :roles_users, [:role_id] - add_index :groups_users, [:user_id] - add_index :groups_users, [:group_id] - add_index :organizations_users, [:user_id] - add_index :organizations_users, [:organization_id] - - end -end From ebea6e3941b924d6caa08d7f294b8a81828c1b7c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 30 Jun 2015 16:45:03 +0200 Subject: [PATCH 04/15] Added to_classname() to string class. --- lib/core_ext/string.rb | 15 +++++++++++++++ test/unit/aaa_string_test.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index 063221811..24c70d2c7 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -35,6 +35,21 @@ class String camel_cased_word.gsub(/::/, '/').downcase end +=begin + + filename = 'some/module.rb'.to_classname + + returns + 'Some::Module' + +=end + + def to_classname + camel_cased_word = "#{self}" + camel_cased_word.gsub!(/\.rb$/, '') + camel_cased_word.split('/').map(&:camelize).join('::') + end + # because of mysql inno_db limitations, strip 4 bytes utf8 chars (e. g. emojis) # unfortunaly UTF8mb4 will raise other limitaions of max varchar and lower index sizes # More details: http://pjambet.github.io/blog/emojis-and-mysql/ diff --git a/test/unit/aaa_string_test.rb b/test/unit/aaa_string_test.rb index b9f8b3ca9..5e155ef80 100644 --- a/test/unit/aaa_string_test.rb +++ b/test/unit/aaa_string_test.rb @@ -25,6 +25,36 @@ class AaaStringTest < ActiveSupport::TestCase assert_equal( result, modul.to_filename ) end + test 'to_classname ref' do + modul = 'test' + result = 'test' + modul.to_filename + assert_equal( result, modul ) + + modul = 'some/file' + result = 'some/file' + modul.to_filename + assert_equal( result, modul ) + end + + test 'to_classname function' do + modul = 'test' + result = 'Test' + assert_equal( result, modul.to_classname ) + + modul = 'some/file' + result = 'Some::File' + assert_equal( result, modul.to_classname ) + + modul = 'some/files' + result = 'Some::Files' + assert_equal( result, modul.to_classname ) + + modul = 'some_test/files' + result = 'SomeTest::Files' + assert_equal( result, modul.to_classname ) + end + test 'html2text ref' do html = 'test' result = 'test' From 94b421775615b27c26e2bcfc1c48c9dffc4e2546 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 30 Jun 2015 17:10:22 +0200 Subject: [PATCH 05/15] Added Models class as helper to find references for prepare user merge feature. --- lib/models.rb | 116 ++++++++++++++++++++++++++++++++++++++++ test/unit/model_test.rb | 84 +++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 lib/models.rb create mode 100644 test/unit/model_test.rb diff --git a/lib/models.rb b/lib/models.rb new file mode 100644 index 000000000..4d4f74274 --- /dev/null +++ b/lib/models.rb @@ -0,0 +1,116 @@ +class Models + include ApplicationLib + +=begin + +get list of models + + result = Models.all + +returns + + { + 'Some::Classname1' => { + attributes: ['id', 'name', '...'] + reflections: ...model.reflections... + }, + 'Some::Classname2' => { + attributes: ['id', 'name', '...'] + reflections: ...model.reflections... + }, + } + +=end + + def self.all + all = {} + dir = "#{Rails.root}/app/models/" + Dir.glob( "#{dir}**/*.rb" ) do |entry| + next if entry =~ /application_model/i + next if entry =~ /channel\//i + next if entry =~ /observer\//i + next if entry =~ /store\/provider\//i + entry.gsub!(dir, '') + entry = entry.to_classname + model_class = load_adapter(entry) + next if !model_class + next if !model_class.respond_to? :new + model_object = model_class.new + next if !model_object.respond_to? :attributes + all[model_class] = {} + all[model_class][:attributes] = model_class.attribute_names + all[model_class][:reflections] = model_class.reflections + #puts "rrrr #{all[model_class][:attributes]}" + #puts model.class + #puts " #{model.attribute_names.inspect}" + end + all + end + +=begin + +get reference list of a models + + result = Models.references('User', 2) + +returns + + { + 'Some::Classname1' => { + attributes: ['id', 'name', '...'] + reflections: ...model.reflections... + }, + 'Some::Classname2' => { + attributes: ['id', 'name', '...'] + reflections: ...model.reflections... + }, + } + +=end + + def self.references(object_name, object_id) + object_model = load_adapter(object_name) + object_model.find(object_id) + list = all + references = { + model: {}, + total: 0, + } + + # find relations via attributes + list.each {|model_class, model_attributes| + references[:model][model_class.to_s] = 0 + next if !model_attributes[:attributes] + ['created_by_id', 'updated_by_id'].each {|item| + if model_attributes[:attributes].include?(item) + Rails.logger.info "FOUND (by id) #{model_class}->#{item}!" + references[:model][model_class.to_s] += model_class.where("#{item} = ?", object_id).count + end + } + } + + # find relations via reflections + list.each {|model_class, model_attributes| + next if !model_attributes[:reflections] + model_attributes[:reflections].each{|reflection_key, reflection_value| + next if reflection_value.macro != :belongs_to + if reflection_value.options[:class_name] == object_name + Rails.logger.info "FOUND (by ref without class) #{model_class}->#{reflection_value.name}!" + references[:model][model_class.to_s] += model_class.where("#{reflection_value.name}_id = ?", object_id).count + end + if !reflection_value.options[:class_name] && reflection_value.name == object_name.downcase.to_sym + Rails.logger.info "FOUND (by ref with class) #{model_class}->#{reflection_value.name}!" + references[:model][model_class.to_s] += model_class.where("#{reflection_value.name}_id = ?", object_id).count + end + } + } + + references[:model].each {|k, v| + next if v == 0 + references[:total] += v +puts "#{k}: #{v}" + } + references + end + +end \ No newline at end of file diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb new file mode 100644 index 000000000..6af3d2517 --- /dev/null +++ b/test/unit/model_test.rb @@ -0,0 +1,84 @@ +# encoding: utf-8 +require 'test_helper' + +class ModelTest < ActiveSupport::TestCase + test 'references test' do + + # create base + groups = Group.where( name: 'Users' ) + roles = Role.where( name: ['Agent', 'Admin'] ) + agent1 = User.create_or_update( + login: 'model-agent1@example.com', + firstname: 'Model', + lastname: 'Agent1', + email: 'model-agent1@example.com', + password: 'agentpw', + active: true, + roles: roles, + groups: groups, + updated_at: '2015-02-05 16:37:00', + updated_by_id: 1, + created_by_id: 1, + ) + organization1 = Organization.create_if_not_exists( + name: 'Model Org 1', + updated_at: '2015-02-05 16:37:00', + updated_by_id: 1, + created_by_id: 1, + ) + organization2 = Organization.create_if_not_exists( + name: 'Model Org 2', + updated_at: '2015-02-05 16:37:00', + updated_by_id: agent1.id, + created_by_id: 1, + ) + roles = Role.where( name: 'Customer' ) + customer1 = User.create_or_update( + login: 'model-customer1@example.com', + firstname: 'Model', + lastname: 'Customer1', + email: 'model-customer1@example.com', + password: 'customerpw', + active: true, + organization_id: organization1.id, + roles: roles, + updated_at: '2015-02-05 16:37:00', + updated_by_id: 1, + created_by_id: 1, + ) + customer2 = User.create_or_update( + login: 'model-customer2@example.com', + firstname: 'Model', + lastname: 'Customer2', + email: 'model-customer2@example.com', + password: 'customerpw', + active: true, + organization_id: nil, + roles: roles, + updated_at: '2015-02-05 16:37:00', + updated_by_id: agent1.id, + created_by_id: 1, + ) + customer3 = User.create_or_update( + login: 'model-customer3@example.com', + firstname: 'Model', + lastname: 'Customer3', + email: 'model-customer3@example.com', + password: 'customerpw', + active: true, + organization_id: nil, + roles: roles, + updated_at: '2015-02-05 16:37:00', + updated_by_id: agent1.id, + created_by_id: agent1.id, + ) + + references = Models.references('User', agent1.id) + + assert_equal(references[:model]['User'], 3) + assert_equal(references[:model]['Organization'], 1) + assert_equal(references[:model]['Group'], 0) + assert_equal(references[:total], 6) + end + +end From a9aa324fd003206cb980054c838a20c71aeed9aa Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 00:23:18 +0200 Subject: [PATCH 06/15] Improved logging. --- lib/models.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/models.rb b/lib/models.rb index 4d4f74274..2d812e11b 100644 --- a/lib/models.rb +++ b/lib/models.rb @@ -83,8 +83,10 @@ returns next if !model_attributes[:attributes] ['created_by_id', 'updated_by_id'].each {|item| if model_attributes[:attributes].include?(item) - Rails.logger.info "FOUND (by id) #{model_class}->#{item}!" - references[:model][model_class.to_s] += model_class.where("#{item} = ?", object_id).count + count = model_class.where("#{item} = ?", object_id).count + next if count == 0 + Rails.logger.debug "FOUND (by id) #{model_class}->#{item} #{count}!" + references[:model][model_class.to_s] += count end } } @@ -95,12 +97,16 @@ returns model_attributes[:reflections].each{|reflection_key, reflection_value| next if reflection_value.macro != :belongs_to if reflection_value.options[:class_name] == object_name - Rails.logger.info "FOUND (by ref without class) #{model_class}->#{reflection_value.name}!" - references[:model][model_class.to_s] += model_class.where("#{reflection_value.name}_id = ?", object_id).count + count = model_class.where("#{reflection_value.name}_id = ?", object_id).count + next if count == 0 + Rails.logger.debug "FOUND (by ref without class) #{model_class}->#{reflection_value.name} #{count}!" + references[:model][model_class.to_s] += count end if !reflection_value.options[:class_name] && reflection_value.name == object_name.downcase.to_sym - Rails.logger.info "FOUND (by ref with class) #{model_class}->#{reflection_value.name}!" - references[:model][model_class.to_s] += model_class.where("#{reflection_value.name}_id = ?", object_id).count + count = model_class.where("#{reflection_value.name}_id = ?", object_id).count + next if count == 0 + Rails.logger.debug "FOUND (by ref with class) #{model_class}->#{reflection_value.name} #{count}!" + references[:model][model_class.to_s] += count end } } @@ -108,7 +114,6 @@ returns references[:model].each {|k, v| next if v == 0 references[:total] += v -puts "#{k}: #{v}" } references end From d73784e7fd9eb325ba36742827e454bdfd960af0 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 00:25:05 +0200 Subject: [PATCH 07/15] Added cleanup jobs. --- app/models/activity_stream.rb | 17 ++++++++++++++ app/models/online_notification.rb | 28 ++++++++++++++++++++++++ db/migrate/20150701000001_add_cleanup.rb | 24 ++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 db/migrate/20150701000001_add_cleanup.rb diff --git a/app/models/activity_stream.rb b/app/models/activity_stream.rb index 4ac607f50..242086483 100644 --- a/app/models/activity_stream.rb +++ b/app/models/activity_stream.rb @@ -118,4 +118,21 @@ return all activity entries of an user list end +=begin + +cleanup old stream messages + + ActivityStream.cleanup + +optional you can parse the max oldest stream entries + + ActivityStream.cleanup(4.months) + +=end + + def self.cleanup(diff = 4.months) + ActivityStream.where('created_at < ?', Time.zone.now - diff).delete_all + true + end + end diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb index 96ac1d653..808c93457 100644 --- a/app/models/online_notification.rb +++ b/app/models/online_notification.rb @@ -3,6 +3,7 @@ class OnlineNotification < ApplicationModel belongs_to :type_lookup, class_name: 'TypeLookup' belongs_to :object_lookup, class_name: 'ObjectLookup' + belongs_to :user after_create :notify_clients_after_change after_update :notify_clients_after_change @@ -188,4 +189,31 @@ returns: ) end +=begin + +cleanup old online notifications + + OnlineNotification.cleanup + +=end + + def self.cleanup + OnlineNotification.where('created_at < ?', Time.zone.now - 12.months).delete_all + OnlineNotification.where('seen = ? AND created_at < ?', true, Time.zone.now - 4.months).delete_all + + # notify all agents + users = Ticket::ScreenOptions.agents + users.each {|user| + Sessions.send_to( + user.id, + { + event: 'OnlineNotification::changed', + data: {} + } + ) + } + + true + end + end diff --git a/db/migrate/20150701000001_add_cleanup.rb b/db/migrate/20150701000001_add_cleanup.rb new file mode 100644 index 000000000..fbb0c1f56 --- /dev/null +++ b/db/migrate/20150701000001_add_cleanup.rb @@ -0,0 +1,24 @@ +class AddCleanup < ActiveRecord::Migration + def up + + # delete old entries + Scheduler.create_or_update( + name: 'Delete old activity stream entries.', + method: 'ActivityStream.cleanup', + period: 1.day, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, + ) + Scheduler.create_or_update( + name: 'Delete old online notification entries.', + method: 'OnlineNotification.cleanup', + period: 1.day, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, + ) + end +end From d685c8f2642016d17ef479595b7aafc7237c1abe Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 00:26:02 +0200 Subject: [PATCH 08/15] Small improvements. --- app/models/scheduler.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb index 5cfe820ac..2eee1b719 100644 --- a/app/models/scheduler.rb +++ b/app/models/scheduler.rb @@ -26,7 +26,7 @@ class Scheduler < ApplicationModel end # read/load jobs and check if it is alredy started - jobs = Scheduler.where( 'active = ?', true ) + jobs = Scheduler.where( 'active = ?', true ).order('prio ASC') jobs.each {|job| # ignore job is still running @@ -37,14 +37,14 @@ class Scheduler < ApplicationModel # run job as own thread @@jobs_started[ job.id ] = true - start_job( job ) + start_job(job) + sleep 10 } sleep 60 end end def self.start_job( job ) - sleep 4 Thread.new { @@ -53,8 +53,8 @@ class Scheduler < ApplicationModel # start loop for periods under 5 minutes if job.period && job.period <= 300 loop do - _start_job( job ) - job = Scheduler.lookup( id: job.id ) + _start_job(job) + job = Scheduler.lookup(id: job.id) # exit is job got deleted break if !job @@ -69,7 +69,7 @@ class Scheduler < ApplicationModel sleep job.period end else - _start_job( job ) + _start_job(job) end job.pid = '' job.save @@ -82,7 +82,6 @@ class Scheduler < ApplicationModel end def self._start_job( job, try_count = 0, try_run_time = Time.zone.now ) - sleep 5 begin job.last_run = Time.zone.now job.pid = Thread.current.object_id From e2c66124fc8970f581d807ed44d9a421b94af2c5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 00:26:24 +0200 Subject: [PATCH 09/15] Improved doc. --- app/models/ticket/screen_options.rb | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/ticket/screen_options.rb b/app/models/ticket/screen_options.rb index 0880b32e1..6ff37e375 100644 --- a/app/models/ticket/screen_options.rb +++ b/app/models/ticket/screen_options.rb @@ -6,7 +6,7 @@ module Ticket::ScreenOptions list of active agents - result = Ticket::ScreenOptions.agents() + result = Ticket::ScreenOptions.agents returns @@ -23,21 +23,21 @@ returns list attributes result = Ticket::ScreenOptions.attributes_to_change( - :ticket_id => 123, - :article_id => 123, + ticket_id: 123, + article_id: 123, - :ticket => ticket_model, + ticket: ticket_model, ) returns result = { - :type_id => type_ids, - :state_id => state_ids, - :priority_id => priority_ids, - :owner_id => owner_ids, - :group_id => group_ids, - :group_id__owner_id => groups_users, + type_id: type_ids, + state_id: state_ids, + priority_id: priority_ids, + owner_id: owner_ids, + group_id: group_ids, + group_id__owner_id: groups_users, } =end @@ -126,16 +126,16 @@ returns list tickets by customer groupd in state categroie open and closed result = Ticket::ScreenOptions.list_by_customer( - :customer_id => 123, - :limit => 15, # optional, default 15 + customer_id: 123, + limit: 15, # optional, default 15 ) returns result = { - :ticket_ids_open => tickets_open, - :ticket_ids_closed => tickets_closed, - :assets => { ...list of assets... }, + ticket_ids_open: tickets_open, + ticket_ids_closed: tickets_closed, + assets: { ...list of assets... }, } =end From ec46aca820bbddd230375d9f649059ff1b1a4562 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 00:33:45 +0200 Subject: [PATCH 10/15] Improved cleanup. --- app/models/online_notification.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb index 808c93457..9b48f0150 100644 --- a/app/models/online_notification.rb +++ b/app/models/online_notification.rb @@ -199,7 +199,7 @@ cleanup old online notifications def self.cleanup OnlineNotification.where('created_at < ?', Time.zone.now - 12.months).delete_all - OnlineNotification.where('seen = ? AND created_at < ?', true, Time.zone.now - 4.months).delete_all + OnlineNotification.where('seen = ? AND created_at < ?', true, Time.zone.now - 2.days).delete_all # notify all agents users = Ticket::ScreenOptions.agents @@ -211,6 +211,7 @@ cleanup old online notifications data: {} } ) + sleep 2 # slow down client requests } true From a4323a7f9945596b191380b005c4e49786da965a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 00:45:15 +0200 Subject: [PATCH 11/15] Improved cleanup again, reduced time to remove of old seen messages. --- app/models/online_notification.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb index 9b48f0150..ed5907408 100644 --- a/app/models/online_notification.rb +++ b/app/models/online_notification.rb @@ -199,7 +199,7 @@ cleanup old online notifications def self.cleanup OnlineNotification.where('created_at < ?', Time.zone.now - 12.months).delete_all - OnlineNotification.where('seen = ? AND created_at < ?', true, Time.zone.now - 2.days).delete_all + OnlineNotification.where('seen = ? AND created_at < ?', true, Time.zone.now - 1.days).delete_all # notify all agents users = Ticket::ScreenOptions.agents From 18a21170a243234bfccdd763054796ab99947ad2 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 01:31:21 +0200 Subject: [PATCH 12/15] Improved cleanup again, reduced time to remove of old messages. --- app/models/activity_stream.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/activity_stream.rb b/app/models/activity_stream.rb index 242086483..787a9ef60 100644 --- a/app/models/activity_stream.rb +++ b/app/models/activity_stream.rb @@ -126,11 +126,11 @@ cleanup old stream messages optional you can parse the max oldest stream entries - ActivityStream.cleanup(4.months) + ActivityStream.cleanup(3.months) =end - def self.cleanup(diff = 4.months) + def self.cleanup(diff = 3.months) ActivityStream.where('created_at < ?', Time.zone.now - diff).delete_all true end From d8001f3c17a31efe02b7c8928a24e0a0f2a41921 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 01:38:16 +0200 Subject: [PATCH 13/15] Added cleanup job. --- app/models/recent_view.rb | 18 ++++++++++++++++++ db/migrate/20150701000002_add_cleanup2.rb | 15 +++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 db/migrate/20150701000002_add_cleanup2.rb diff --git a/app/models/recent_view.rb b/app/models/recent_view.rb index bb093bdcf..5d82fa40a 100644 --- a/app/models/recent_view.rb +++ b/app/models/recent_view.rb @@ -98,4 +98,22 @@ class RecentView < ApplicationModel return if !record.respond_to?(:permission) record.permission( current_user: user ) end + +=begin + +cleanup old entries + + RecentView.cleanup + +optional you can parse the max oldest entries + + RecentView.cleanup(1.month) + +=end + + def self.cleanup(diff = 1.month) + RecentView.where('created_at < ?', Time.zone.now - diff).delete_all + true + end + end diff --git a/db/migrate/20150701000002_add_cleanup2.rb b/db/migrate/20150701000002_add_cleanup2.rb new file mode 100644 index 000000000..010324e5c --- /dev/null +++ b/db/migrate/20150701000002_add_cleanup2.rb @@ -0,0 +1,15 @@ +class AddCleanup2 < ActiveRecord::Migration + def up + + # delete old entries + Scheduler.create_or_update( + name: 'Delete old entries.', + method: 'RecentView.cleanup', + period: 1.day, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, + ) + end +end From ab53bbc3a7981a02d47352706949f5f88cc58668 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 02:05:13 +0200 Subject: [PATCH 14/15] Merged some migrations. --- .../20130815000002_update_ticket_number.rb | 34 ------------ db/migrate/20130817000001_update_auth.rb | 53 ------------------- db/migrate/20140728000001_update_setting1.rb | 51 ------------------ ...140911000001_update_ticket_article_size.rb | 8 --- db/migrate/20141119000001_update_setting2.rb | 9 ++++ db/migrate/20141120000001_update_setting3.rb | 16 ------ db/migrate/20150701000001_add_cleanup.rb | 9 ++++ db/migrate/20150701000002_add_cleanup2.rb | 15 ------ 8 files changed, 18 insertions(+), 177 deletions(-) delete mode 100644 db/migrate/20130815000002_update_ticket_number.rb delete mode 100644 db/migrate/20130817000001_update_auth.rb delete mode 100644 db/migrate/20140728000001_update_setting1.rb delete mode 100644 db/migrate/20140911000001_update_ticket_article_size.rb delete mode 100644 db/migrate/20141120000001_update_setting3.rb delete mode 100644 db/migrate/20150701000002_add_cleanup2.rb diff --git a/db/migrate/20130815000002_update_ticket_number.rb b/db/migrate/20130815000002_update_ticket_number.rb deleted file mode 100644 index 11949d58b..000000000 --- a/db/migrate/20130815000002_update_ticket_number.rb +++ /dev/null @@ -1,34 +0,0 @@ -class UpdateTicketNumber < ActiveRecord::Migration - def up - Setting.create_or_update( - title: 'Ticket Number Format', - name: 'ticket_number', - area: 'Ticket::Number', - description: 'Selects the ticket number generator module. "Increment" increments the ticket - number, the SystemID and the counter are used with SystemID.Counter format (e.g. 1010138, 1010139). - With "Date" the ticket numbers will be generated by the current date, the SystemID and the counter. - The format looks like Year.Month.Day.SystemID.counter (e.g. 201206231010138, 201206231010139). - With param "Checksum => true" the counter will be appended as checksum to the string. The format - looks like SystemID.Counter.CheckSum (e. g. 10101384, 10101392) or Year.Month.Day.SystemID.Counter.CheckSum (e.g. 2012070110101520, 2012070110101535).', - options: { - form: [ - { - display: '', - null: true, - name: 'ticket_number', - tag: 'select', - options: { - 'Ticket::Number::Increment' => 'Increment (SystemID.Counter)', - 'Ticket::Number::Date' => 'Date (Year.Month.Day.SystemID.Counter)', - }, - }, - ], - }, - state: 'Ticket::Number::Increment', - frontend: false - ) - end - - def down - end -end diff --git a/db/migrate/20130817000001_update_auth.rb b/db/migrate/20130817000001_update_auth.rb deleted file mode 100644 index 559c42456..000000000 --- a/db/migrate/20130817000001_update_auth.rb +++ /dev/null @@ -1,53 +0,0 @@ -class UpdateAuth < ActiveRecord::Migration - def up - Setting.create_or_update( - title: 'Authentication via OTRS', - name: 'auth_otrs', - area: 'Security::Authentication', - description: 'Enables user authentication via OTRS.', - state: { - adapter: 'Auth::Otrs', - required_group_ro: 'stats', - group_rw_role_map: { - 'admin' => 'Admin', - 'stats' => 'Report', - }, - group_ro_role_map: { - 'stats' => 'Report', - }, - always_role: { - 'Agent' => true, - }, - }, - frontend: false - ) - Setting.create_or_update( - title: 'Authentication via LDAP', - name: 'auth_ldap', - area: 'Security::Authentication', - description: 'Enables user authentication via LDAP.', - state: { - adapter: 'Auth::Ldap', - host: 'localhost', - port: 389, - bind_dn: 'cn=Manager,dc=example,dc=org', - bind_pw: 'example', - uid: 'mail', - base: 'dc=example,dc=org', - always_filter: '', - always_roles: %w(Admin Agent), - always_groups: ['Users'], - sync_params: { - firstname: 'sn', - lastname: 'givenName', - email: 'mail', - login: 'mail', - }, - }, - frontend: false - ) - end - - def down - end -end diff --git a/db/migrate/20140728000001_update_setting1.rb b/db/migrate/20140728000001_update_setting1.rb deleted file mode 100644 index 134aa334f..000000000 --- a/db/migrate/20140728000001_update_setting1.rb +++ /dev/null @@ -1,51 +0,0 @@ -class UpdateSetting1 < ActiveRecord::Migration - def up - Setting.create_if_not_exists( - title: 'Send client stats', - name: 'ui_send_client_stats', - area: 'System::UI', - description: 'Send client stats to central server.', - options: { - form: [ - { - display: '', - null: true, - name: 'ui_send_client_stats', - tag: 'boolean', - options: { - true => 'yes', - false => 'no', - }, - }, - ], - }, - state: true, - frontend: true - ) - Setting.create_if_not_exists( - title: 'Client storage', - name: 'ui_client_storage', - area: 'System::UI', - description: 'Use client storage to cache data to perform speed of application.', - options: { - form: [ - { - display: '', - null: true, - name: 'ui_client_storage', - tag: 'boolean', - options: { - true => 'yes', - false => 'no', - }, - }, - ], - }, - state: false, - frontend: true - ) - end - - def down - end -end diff --git a/db/migrate/20140911000001_update_ticket_article_size.rb b/db/migrate/20140911000001_update_ticket_article_size.rb deleted file mode 100644 index 372491f58..000000000 --- a/db/migrate/20140911000001_update_ticket_article_size.rb +++ /dev/null @@ -1,8 +0,0 @@ -class UpdateTicketArticleSize < ActiveRecord::Migration - def up - change_column :ticket_articles, :body, :text, limit: 4.megabytes + 1 - end - - def down - end -end diff --git a/db/migrate/20141119000001_update_setting2.rb b/db/migrate/20141119000001_update_setting2.rb index cf81cb713..021863b75 100644 --- a/db/migrate/20141119000001_update_setting2.rb +++ b/db/migrate/20141119000001_update_setting2.rb @@ -18,6 +18,15 @@ class UpdateSetting2 < ActiveRecord::Migration state: 'logo.svg', frontend: true ) + Setting.create_if_not_exists( + title: 'Online Service', + name: 'system_online_service', + area: 'Core', + description: 'Defines if application is used as online service.', + options: {}, + state: false, + frontend: true + ) end def down diff --git a/db/migrate/20141120000001_update_setting3.rb b/db/migrate/20141120000001_update_setting3.rb deleted file mode 100644 index fee652b2f..000000000 --- a/db/migrate/20141120000001_update_setting3.rb +++ /dev/null @@ -1,16 +0,0 @@ -class UpdateSetting3 < ActiveRecord::Migration - def up - Setting.create_if_not_exists( - title: 'Online Service', - name: 'system_online_service', - area: 'Core', - description: 'Defines if application is used as online service.', - options: {}, - state: false, - frontend: true - ) - end - - def down - end -end diff --git a/db/migrate/20150701000001_add_cleanup.rb b/db/migrate/20150701000001_add_cleanup.rb index fbb0c1f56..025ee968f 100644 --- a/db/migrate/20150701000001_add_cleanup.rb +++ b/db/migrate/20150701000001_add_cleanup.rb @@ -20,5 +20,14 @@ class AddCleanup < ActiveRecord::Migration updated_by_id: 1, created_by_id: 1, ) + Scheduler.create_or_update( + name: 'Delete old entries.', + method: 'RecentView.cleanup', + period: 1.day, + prio: 2, + active: true, + updated_by_id: 1, + created_by_id: 1, + ) end end diff --git a/db/migrate/20150701000002_add_cleanup2.rb b/db/migrate/20150701000002_add_cleanup2.rb deleted file mode 100644 index 010324e5c..000000000 --- a/db/migrate/20150701000002_add_cleanup2.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddCleanup2 < ActiveRecord::Migration - def up - - # delete old entries - Scheduler.create_or_update( - name: 'Delete old entries.', - method: 'RecentView.cleanup', - period: 1.day, - prio: 2, - active: true, - updated_by_id: 1, - created_by_id: 1, - ) - end -end From 9babb669b4b360e1791d22f38f213f6afe9cde7d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jul 2015 03:08:01 +0200 Subject: [PATCH 15/15] Merged some migrations. --- db/migrate/20120101000001_create_base.rb | 35 ++++++ db/migrate/20120101000010_create_ticket.rb | 59 +++++++++++ db/migrate/20120101000030_create_storage.rb | 44 -------- db/migrate/20120101000090_create_template.rb | 26 ----- ...20120101000100_postmaster_filter_create.rb | 19 ---- .../20120101000110_text_module_create.rb | 30 ------ db/migrate/20140128000001_add_search_index.rb | 59 ----------- db/migrate/20141119000001_update_setting2.rb | 34 ------ db/migrate/20141126000001_create_avatar.rb | 2 +- .../20141217000001_update_object_manager2.rb | 39 ++++++- .../20141227000001_update_ticket_article.rb | 8 -- db/migrate/20141231000001_add_develop_mode.rb | 16 --- db/migrate/20150206000001_create_vip.rb | 47 -------- .../20150208000001_update_object_manager3.rb | 100 ------------------ .../20150215082745_rename_avatar_typo.rb | 9 -- .../20150322000001_update_geo_ip_config.rb | 30 ------ db/seeds.rb | 49 +++++++++ 17 files changed, 182 insertions(+), 424 deletions(-) delete mode 100644 db/migrate/20120101000030_create_storage.rb delete mode 100644 db/migrate/20120101000090_create_template.rb delete mode 100644 db/migrate/20120101000100_postmaster_filter_create.rb delete mode 100644 db/migrate/20120101000110_text_module_create.rb delete mode 100644 db/migrate/20140128000001_add_search_index.rb delete mode 100644 db/migrate/20141119000001_update_setting2.rb delete mode 100644 db/migrate/20141227000001_update_ticket_article.rb delete mode 100644 db/migrate/20141231000001_add_develop_mode.rb delete mode 100644 db/migrate/20150206000001_create_vip.rb delete mode 100644 db/migrate/20150208000001_update_object_manager3.rb delete mode 100644 db/migrate/20150215082745_rename_avatar_typo.rb delete mode 100644 db/migrate/20150322000001_update_geo_ip_config.rb diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 2bc455343..45df4af0b 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -27,6 +27,7 @@ class CreateBase < ActiveRecord::Migration t.column :zip, :string, limit: 100, null: true, default: '' t.column :city, :string, limit: 100, null: true, default: '' t.column :country, :string, limit: 100, null: true, default: '' + t.column :vip, :boolean, default: false t.column :verified, :boolean, null: false, default: false t.column :active, :boolean, null: false, default: true t.column :note, :string, limit: 250, null: true, default: '' @@ -316,5 +317,39 @@ class CreateBase < ActiveRecord::Migration add_index :settings, [:area] add_index :settings, [:frontend] + create_table :stores do |t| + t.references :store_object, null: false + t.references :store_file, null: false + t.column :o_id, :integer, limit: 8, null: false + t.column :preferences, :string, limit: 2500, null: true + t.column :size, :string, limit: 50, null: true + t.column :filename, :string, limit: 250, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :stores, [:store_object_id, :o_id] + + create_table :store_objects do |t| + t.column :name, :string, limit: 250, null: false + t.column :note, :string, limit: 250, null: true + t.timestamps + end + add_index :store_objects, [:name], unique: true + + create_table :store_files do |t| + t.column :sha, :string, limit: 128, null: false + t.column :provider, :string, limit: 20, null: true + t.timestamps + end + add_index :store_files, [:sha], unique: true + add_index :store_files, [:provider] + + create_table :store_provider_dbs do |t| + t.column :sha, :string, limit: 128, null: false + t.column :data, :binary, limit: 200.megabytes, null: true + t.timestamps + end + add_index :store_provider_dbs, [:sha], unique: true + end end diff --git a/db/migrate/20120101000010_create_ticket.rb b/db/migrate/20120101000010_create_ticket.rb index ba38be820..86053b439 100644 --- a/db/migrate/20120101000010_create_ticket.rb +++ b/db/migrate/20120101000010_create_ticket.rb @@ -145,6 +145,7 @@ class CreateTicket < ActiveRecord::Migration t.column :message_id, :string, limit: 3000, null: true t.column :message_id_md5, :string, limit: 32, null: true t.column :in_reply_to, :string, limit: 3000, null: true + t.column :content_type, :string, limit: 20, null: false, default: 'text/plain' t.column :references, :string, limit: 3200, null: true t.column :body, :text, limit: 4.megabytes + 1 t.column :internal, :boolean, null: false, default: false @@ -248,9 +249,67 @@ class CreateTicket < ActiveRecord::Migration t.timestamps end add_index :links, [:link_object_source_id, :link_object_source_value, :link_object_target_id, :link_object_target_value, :link_type_id], unique: true, name: 'links_uniq_total' + + create_table :postmaster_filters do |t| + t.column :name, :string, limit: 250, null: false + t.column :channel, :string, limit: 250, null: false + t.column :match, :string, limit: 5000, null: false + t.column :perform, :string, limit: 5000, null: false + t.column :active, :boolean, null: false, default: true + t.column :note, :string, limit: 250, null: true + t.column :updated_by_id, :integer, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :postmaster_filters, [:channel] + + create_table :text_modules do |t| + t.references :user, null: true + t.column :name, :string, limit: 250, null: false + t.column :keywords, :string, limit: 500, null: true + t.column :content, :string, limit: 5000, null: false + t.column :note, :string, limit: 250, null: true + t.column :active, :boolean, null: false, default: true + t.column :updated_by_id, :integer, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :text_modules, [:user_id] + add_index :text_modules, [:name] + + create_table :text_modules_groups, id: false do |t| + t.integer :text_module_id + t.integer :group_id + end + add_index :text_modules_groups, [:text_module_id] + add_index :text_modules_groups, [:group_id] + + create_table :templates do |t| + t.references :user, null: true + t.column :name, :string, limit: 250, null: false + t.column :options, :string, limit: 2500, null: false + t.column :updated_by_id, :integer, null: false + t.column :created_by_id, :integer, null: false + t.timestamps + end + add_index :templates, [:user_id] + add_index :templates, [:name] + + create_table :templates_groups, id: false do |t| + t.integer :template_id + t.integer :group_id + end + add_index :templates_groups, [:template_id] + add_index :templates_groups, [:group_id] + end def self.down + drop_table :templates_groups + drop_table :templates + drop_table :text_modules_groups + drop_table :text_modules + drop_table :postmaster_filters drop_table :notifications drop_table :triggers drop_table :links diff --git a/db/migrate/20120101000030_create_storage.rb b/db/migrate/20120101000030_create_storage.rb deleted file mode 100644 index 8812680e0..000000000 --- a/db/migrate/20120101000030_create_storage.rb +++ /dev/null @@ -1,44 +0,0 @@ -class CreateStorage < ActiveRecord::Migration - def up - create_table :stores do |t| - t.references :store_object, null: false - t.references :store_file, null: false - t.column :o_id, :integer, limit: 8, null: false - t.column :preferences, :string, limit: 2500, null: true - t.column :size, :string, limit: 50, null: true - t.column :filename, :string, limit: 250, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :stores, [:store_object_id, :o_id] - - create_table :store_objects do |t| - t.column :name, :string, limit: 250, null: false - t.column :note, :string, limit: 250, null: true - t.timestamps - end - add_index :store_objects, [:name], unique: true - - create_table :store_files do |t| - t.column :sha, :string, limit: 128, null: false - t.column :provider, :string, limit: 20, null: true - t.timestamps - end - add_index :store_files, [:sha], unique: true - add_index :store_files, [:provider] - - create_table :store_provider_dbs do |t| - t.column :sha, :string, limit: 128, null: false - t.column :data, :binary, limit: 200.megabytes, null: true - t.timestamps - end - add_index :store_provider_dbs, [:sha], unique: true - - end - - def down - drop_table :stores - drop_table :store_objects - drop_table :store_files - end -end diff --git a/db/migrate/20120101000090_create_template.rb b/db/migrate/20120101000090_create_template.rb deleted file mode 100644 index 52e8f9ffc..000000000 --- a/db/migrate/20120101000090_create_template.rb +++ /dev/null @@ -1,26 +0,0 @@ -class CreateTemplate < ActiveRecord::Migration - def up - create_table :templates do |t| - t.references :user, null: true - t.column :name, :string, limit: 250, null: false - t.column :options, :string, limit: 2500, null: false - t.column :updated_by_id, :integer, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :templates, [:user_id] - add_index :templates, [:name] - - create_table :templates_groups, id: false do |t| - t.integer :template_id - t.integer :group_id - end - add_index :templates_groups, [:template_id] - add_index :templates_groups, [:group_id] - end - - def down - drop_table :templates_groups - drop_table :templates - end -end diff --git a/db/migrate/20120101000100_postmaster_filter_create.rb b/db/migrate/20120101000100_postmaster_filter_create.rb deleted file mode 100644 index 7f0702643..000000000 --- a/db/migrate/20120101000100_postmaster_filter_create.rb +++ /dev/null @@ -1,19 +0,0 @@ -class PostmasterFilterCreate < ActiveRecord::Migration - def up - create_table :postmaster_filters do |t| - t.column :name, :string, limit: 250, null: false - t.column :channel, :string, limit: 250, null: false - t.column :match, :string, limit: 5000, null: false - t.column :perform, :string, limit: 5000, null: false - t.column :active, :boolean, null: false, default: true - t.column :note, :string, limit: 250, null: true - t.column :updated_by_id, :integer, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :postmaster_filters, [:channel] - end - - def down - end -end diff --git a/db/migrate/20120101000110_text_module_create.rb b/db/migrate/20120101000110_text_module_create.rb deleted file mode 100644 index d8c995aee..000000000 --- a/db/migrate/20120101000110_text_module_create.rb +++ /dev/null @@ -1,30 +0,0 @@ -class TextModuleCreate < ActiveRecord::Migration - def up - create_table :text_modules do |t| - t.references :user, null: true - t.column :name, :string, limit: 250, null: false - t.column :keywords, :string, limit: 500, null: true - t.column :content, :string, limit: 5000, null: false - t.column :note, :string, limit: 250, null: true - t.column :active, :boolean, null: false, default: true - t.column :updated_by_id, :integer, null: false - t.column :created_by_id, :integer, null: false - t.timestamps - end - add_index :text_modules, [:user_id] - add_index :text_modules, [:name] - - create_table :text_modules_groups, id: false do |t| - t.integer :text_module_id - t.integer :group_id - end - add_index :text_modules_groups, [:text_module_id] - add_index :text_modules_groups, [:group_id] - end - - def down - drop_table :text_modules_groups - drop_table :text_modules - end - -end diff --git a/db/migrate/20140128000001_add_search_index.rb b/db/migrate/20140128000001_add_search_index.rb deleted file mode 100644 index 114d3dbaf..000000000 --- a/db/migrate/20140128000001_add_search_index.rb +++ /dev/null @@ -1,59 +0,0 @@ -class AddSearchIndex < ActiveRecord::Migration - def up - Setting.create_or_update( - title: 'Elasticsearch Endpoint URL', - name: 'es_url', - area: 'SearchIndex::Elasticsearch', - description: 'Define endpoint of Elastic Search.', - state: '', - frontend: false - ) - Setting.create_or_update( - title: 'Elasticsearch Endpoint User', - name: 'es_user', - area: 'SearchIndex::Elasticsearch', - description: 'Define http basic auth user of Elasticsearch.', - state: '', - frontend: false - ) - Setting.create_or_update( - title: 'Elastic Search Endpoint Password', - name: 'es_password', - area: 'SearchIndex::Elasticsearch', - description: 'Define http basic auth password of Elasticsearch.', - state: '', - frontend: false - ) - Setting.create_or_update( - title: 'Elastic Search Endpoint Index', - name: 'es_index', - area: 'SearchIndex::Elasticsearch', - description: 'Define Elasticsearch index name.', - state: 'zammad', - frontend: false - ) - Setting.create_or_update( - title: 'Elastic Search Attachment Extentions', - name: 'es_attachment_ignore', - area: 'SearchIndex::Elasticsearch', - description: 'Define attachment extentions which are ignored for Elasticsearch.', - state: [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ], - frontend: false - ) - Setting.create_or_update( - title: 'Elastic Search Attachment Size', - name: 'es_attachment_max_size_in_mb', - area: 'SearchIndex::Elasticsearch', - description: 'Define max. attachment size for Elasticsearch.', - state: 50, - frontend: false - ) - - Ticket.search_index_reload - User.search_index_reload - Organization.search_index_reload - end - - def down - end -end diff --git a/db/migrate/20141119000001_update_setting2.rb b/db/migrate/20141119000001_update_setting2.rb deleted file mode 100644 index 021863b75..000000000 --- a/db/migrate/20141119000001_update_setting2.rb +++ /dev/null @@ -1,34 +0,0 @@ -class UpdateSetting2 < ActiveRecord::Migration - def up - Setting.create_if_not_exists( - title: 'Logo', - name: 'product_logo', - area: 'System::CI', - description: 'Defines the logo of the application, shown in the web interface.', - options: { - form: [ - { - display: '', - null: false, - name: 'product_logo', - tag: 'input', - }, - ], - }, - state: 'logo.svg', - frontend: true - ) - Setting.create_if_not_exists( - title: 'Online Service', - name: 'system_online_service', - area: 'Core', - description: 'Defines if application is used as online service.', - options: {}, - state: false, - frontend: true - ) - end - - def down - end -end diff --git a/db/migrate/20141126000001_create_avatar.rb b/db/migrate/20141126000001_create_avatar.rb index adb15706a..3b267ad98 100644 --- a/db/migrate/20141126000001_create_avatar.rb +++ b/db/migrate/20141126000001_create_avatar.rb @@ -5,7 +5,7 @@ class CreateAvatar < ActiveRecord::Migration t.column :object_lookup_id, :integer, null: false t.column :default, :boolean, null: false, default: false t.column :deletable, :boolean, null: false, default: true - t.column :inital, :boolean, null: false, default: false + t.column :initial, :boolean, null: false, default: false t.column :store_full_id, :integer, null: true t.column :store_resize_id, :integer, null: true t.column :store_hash, :string, limit: 32, null: true diff --git a/db/migrate/20141217000001_update_object_manager2.rb b/db/migrate/20141217000001_update_object_manager2.rb index 69e5058a4..a78bc14a5 100644 --- a/db/migrate/20141217000001_update_object_manager2.rb +++ b/db/migrate/20141217000001_update_object_manager2.rb @@ -487,6 +487,44 @@ class UpdateObjectManager2 < ActiveRecord::Migration updated_by_id: 1, ) + ObjectManager::Attribute.add( + object: 'User', + name: 'vip', + display: 'VIP', + data_type: 'boolean', + data_option: { + null: true, + default: false, + item_class: 'formGroup--halfSize', + options: { + false: 'no', + true: 'yes', + }, + translate: true, + }, + editable: false, + active: true, + screens: { + edit: { + Admin: { + null: true, + }, + Agent: { + null: true, + }, + }, + view: { + '-all-' => { + shown: false, + }, + }, + }, + pending_migration: false, + position: 1490, + created_by_id: 1, + updated_by_id: 1, + ) + ObjectManager::Attribute.add( object: 'User', name: 'note', @@ -594,7 +632,6 @@ class UpdateObjectManager2 < ActiveRecord::Migration display: 'Active', data_type: 'active', data_option: { - null: true, default: true, }, editable: false, diff --git a/db/migrate/20141227000001_update_ticket_article.rb b/db/migrate/20141227000001_update_ticket_article.rb deleted file mode 100644 index 35e60c89c..000000000 --- a/db/migrate/20141227000001_update_ticket_article.rb +++ /dev/null @@ -1,8 +0,0 @@ -class UpdateTicketArticle < ActiveRecord::Migration - def up - add_column :ticket_articles, :content_type, :string, limit: 20, null: false, default: 'text/plain' - end - - def down - end -end diff --git a/db/migrate/20141231000001_add_develop_mode.rb b/db/migrate/20141231000001_add_develop_mode.rb deleted file mode 100644 index 36309fba6..000000000 --- a/db/migrate/20141231000001_add_develop_mode.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AddDevelopMode < ActiveRecord::Migration - def up - Setting.create_if_not_exists( - title: 'Develop System', - name: 'developer_mode', - area: 'Core::Develop', - description: 'Defines if application is in developer mode (useful for developer, all users have the same password, password reset will work without email delivery).', - options: {}, - state: false, - frontend: true - ) - end - - def down - end -end diff --git a/db/migrate/20150206000001_create_vip.rb b/db/migrate/20150206000001_create_vip.rb deleted file mode 100644 index fd48bee4b..000000000 --- a/db/migrate/20150206000001_create_vip.rb +++ /dev/null @@ -1,47 +0,0 @@ -class CreateVip < ActiveRecord::Migration - def up - add_column :users, :vip, :boolean, default: false - - ObjectManager::Attribute.add( - object: 'User', - name: 'vip', - display: 'VIP', - data_type: 'boolean', - data_option: { - null: true, - default: false, - item_class: 'formGroup--halfSize', - options: { - false: 'no', - true: 'yes', - }, - translate: true, - }, - editable: false, - active: true, - screens: { - edit: { - Admin: { - null: true, - }, - Agent: { - null: true, - }, - }, - view: { - '-all-' => { - shown: false, - }, - }, - }, - pending_migration: false, - position: 1490, - created_by_id: 1, - updated_by_id: 1, - ) - - end - - def down - end -end diff --git a/db/migrate/20150208000001_update_object_manager3.rb b/db/migrate/20150208000001_update_object_manager3.rb deleted file mode 100644 index 6ff3b8b88..000000000 --- a/db/migrate/20150208000001_update_object_manager3.rb +++ /dev/null @@ -1,100 +0,0 @@ -class UpdateObjectManager3 < ActiveRecord::Migration - def up - - ObjectManager::Attribute.add( - object: 'User', - name: 'active', - display: 'Active', - data_type: 'active', - data_option: { - default: true, - }, - editable: false, - active: true, - screens: { - signup: {}, - invite_agent: {}, - edit: { - Admin: { - null: false, - }, - }, - view: { - '-all-' => { - shown: false, - }, - }, - }, - pending_migration: false, - position: 1800, - created_by_id: 1, - updated_by_id: 1, - ) - - ObjectManager::Attribute.add( - object: 'Organization', - name: 'active', - display: 'Active', - data_type: 'active', - data_option: { - default: true, - }, - editable: false, - active: true, - screens: { - edit: { - Admin: { - null: false, - }, - }, - view: { - '-all-' => { - shown: false, - }, - }, - }, - pending_migration: false, - position: 1800, - created_by_id: 1, - updated_by_id: 1, - ) - - ObjectManager::Attribute.add( - object: 'User', - name: 'password', - display: 'Password', - data_type: 'input', - data_option: { - type: 'password', - maxlength: 100, - null: true, - autocomplete: 'off', - item_class: 'formGroup--halfSize', - }, - editable: false, - active: true, - screens: { - signup: { - '-all-' => { - null: false, - }, - }, - invite_agent: {}, - edit: { - Admin: { - null: true, - }, - }, - view: {} - }, - pending_migration: false, - position: 1400, - created_by_id: 1, - updated_by_id: 1, - ) - - end - - def down - end -end diff --git a/db/migrate/20150215082745_rename_avatar_typo.rb b/db/migrate/20150215082745_rename_avatar_typo.rb deleted file mode 100644 index d0f9abcc5..000000000 --- a/db/migrate/20150215082745_rename_avatar_typo.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RenameAvatarTypo < ActiveRecord::Migration - def up - rename_column :avatars, :inital, :initial - end - - def down - rename_column :avatars, :initial, :inital - end -end diff --git a/db/migrate/20150322000001_update_geo_ip_config.rb b/db/migrate/20150322000001_update_geo_ip_config.rb deleted file mode 100644 index b16528a3f..000000000 --- a/db/migrate/20150322000001_update_geo_ip_config.rb +++ /dev/null @@ -1,30 +0,0 @@ -class UpdateGeoIpConfig < ActiveRecord::Migration - def up - Setting.create_or_update( - title: 'Geo IP Backend', - name: 'geo_ip_backend', - area: 'System::Geo', - description: 'Defines the backend for geo ip lookups.', - options: { - form: [ - { - display: '', - null: true, - name: 'geo_ip_backend', - tag: 'select', - options: { - '' => '-', - 'GeoIp::ZammadGeoIp' => 'Zammad GeoIP Service', - }, - }, - ], - }, - state: 'GeoIp::ZammadGeoIp', - frontend: false - ) - end - - def down - end - -end diff --git a/db/seeds.rb b/db/seeds.rb index 67402ce53..c8294811b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1130,6 +1130,55 @@ Setting.create_if_not_exists( frontend: true ) +Setting.create_if_not_exists( + title: 'Elasticsearch Endpoint URL', + name: 'es_url', + area: 'SearchIndex::Elasticsearch', + description: 'Define endpoint of Elastic Search.', + state: '', + frontend: false +) +Setting.create_if_not_exists( + title: 'Elasticsearch Endpoint User', + name: 'es_user', + area: 'SearchIndex::Elasticsearch', + description: 'Define http basic auth user of Elasticsearch.', + state: '', + frontend: false +) +Setting.create_if_not_exists( + title: 'Elastic Search Endpoint Password', + name: 'es_password', + area: 'SearchIndex::Elasticsearch', + description: 'Define http basic auth password of Elasticsearch.', + state: '', + frontend: false +) +Setting.create_if_not_exists( + title: 'Elastic Search Endpoint Index', + name: 'es_index', + area: 'SearchIndex::Elasticsearch', + description: 'Define Elasticsearch index name.', + state: 'zammad', + frontend: false +) +Setting.create_if_not_exists( + title: 'Elastic Search Attachment Extentions', + name: 'es_attachment_ignore', + area: 'SearchIndex::Elasticsearch', + description: 'Define attachment extentions which are ignored for Elasticsearch.', + state: [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ], + frontend: false +) +Setting.create_if_not_exists( + title: 'Elastic Search Attachment Size', + name: 'es_attachment_max_size_in_mb', + area: 'SearchIndex::Elasticsearch', + description: 'Define max. attachment size for Elasticsearch.', + state: 50, + frontend: false +) + Setting.create_if_not_exists( title: 'Import Mode', name: 'import_mode',