forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue zammad#2292 - CTI Log: duration_talking_time is incorrect…
… and after update initialized_at is a string (not timestamp)
- Loading branch information
1 parent
fb24de1
commit 86c2df6
Showing
6 changed files
with
174 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class CtiGenericApi2 < ActiveRecord::Migration[5.1] | ||
def up | ||
|
||
# return if it's a new setup | ||
return if !Setting.find_by(name: 'system_init_done') | ||
return if !column_exists?(:cti_logs, :initialized_at) | ||
return if !column_exists?(:cti_logs, :initialized_at_cleanup) | ||
|
||
add_column :cti_logs, :initialized_at_cleanup, :timestamp, limit: 3, null: true | ||
Cti::Log.connection.schema_cache.clear! | ||
Cti::Log.reset_column_information | ||
|
||
# clenaup table records | ||
Cti::Log.order(created_at: :desc).limit(2000).each do |log| | ||
if log.initialized_at | ||
begin | ||
initialized_at = Time.zone.parse(log.initialized_at) | ||
log.update_column(:initialized_at_cleanup, initialized_at) # rubocop:disable Rails/SkipsModelValidations | ||
if initialized_at && log.start_at | ||
log.update_column(:duration_waiting_time, log.start_at.to_i - initialized_at.to_i) # rubocop:disable Rails/SkipsModelValidations | ||
end | ||
rescue => e | ||
logger.error e | ||
end | ||
end | ||
if log.end_at && log.start_at | ||
log.update_column(:duration_talking_time, log.end_at.to_i - log.start_at.to_i) # rubocop:disable Rails/SkipsModelValidations | ||
end | ||
end | ||
|
||
remove_column(:cti_logs, :initialized_at) | ||
Cti::Log.connection.schema_cache.clear! | ||
Cti::Log.reset_column_information | ||
|
||
rename_column :cti_logs, :initialized_at_cleanup, :initialized_at | ||
Cti::Log.connection.schema_cache.clear! | ||
Cti::Log.reset_column_information | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters