Corrected with rubocop cop 'Style/IndentationWidth'.
This commit is contained in:
parent
8c2ea52b3c
commit
19feb32c7b
7 changed files with 90 additions and 97 deletions
2
Gemfile
2
Gemfile
|
@ -62,7 +62,7 @@ gem 'em-websocket'
|
|||
# in production environments by default.
|
||||
group :development, :test do
|
||||
|
||||
gem 'test-unit'
|
||||
gem 'test-unit'
|
||||
gem 'spring'
|
||||
gem 'sqlite3'
|
||||
|
||||
|
|
|
@ -105,13 +105,13 @@ curl http://localhost/api/v1/online_notifications/mark_all_as_read -v -u #{login
|
|||
=end
|
||||
|
||||
def mark_all_as_read
|
||||
notifications = OnlineNotification.list(current_user, 100)
|
||||
notifications.each do |notification|
|
||||
if !notification['seen']
|
||||
OnlineNotification.seen( id: notification['id'] )
|
||||
end
|
||||
notifications = OnlineNotification.list(current_user, 100)
|
||||
notifications.each do |notification|
|
||||
if !notification['seen']
|
||||
OnlineNotification.seen( id: notification['id'] )
|
||||
end
|
||||
render json: {}, status: :ok
|
||||
end
|
||||
render json: {}, status: :ok
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -56,7 +56,7 @@ mark online notification as seen
|
|||
=end
|
||||
|
||||
def self.seen(data)
|
||||
notification = OnlineNotification.find(data[:id])
|
||||
notification = OnlineNotification.find(data[:id])
|
||||
notification.seen = true
|
||||
notification.save
|
||||
end
|
||||
|
@ -139,17 +139,17 @@ mark online notification as seen by object
|
|||
=end
|
||||
|
||||
def self.seen_by_object(object_name, o_id)
|
||||
object_id = ObjectLookup.by_name( object_name )
|
||||
notifications = OnlineNotification.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
seen: false,
|
||||
)
|
||||
notifications.each do |notification|
|
||||
notification.seen = true
|
||||
notification.save
|
||||
end
|
||||
true
|
||||
object_id = ObjectLookup.by_name( object_name )
|
||||
notifications = OnlineNotification.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
seen: false,
|
||||
)
|
||||
notifications.each do |notification|
|
||||
notification.seen = true
|
||||
notification.save
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
=begin
|
||||
|
|
|
@ -117,7 +117,7 @@ module Import::OTRS
|
|||
|
||||
# check if system is in import mode
|
||||
if !Setting.get('import_mode')
|
||||
raise 'System is not in import mode!'
|
||||
raise 'System is not in import mode!'
|
||||
end
|
||||
|
||||
response = request('public.pl?Action=Export')
|
||||
|
@ -181,7 +181,7 @@ module Import::OTRS
|
|||
|
||||
# check if system is in import mode
|
||||
if !Setting.get('import_mode')
|
||||
raise 'System is not in import mode!'
|
||||
raise 'System is not in import mode!'
|
||||
end
|
||||
|
||||
# create states
|
||||
|
@ -702,48 +702,44 @@ module Import::OTRS
|
|||
UserEmail: :email,
|
||||
UserFirstname: :firstname,
|
||||
UserLastname: :lastname,
|
||||
# :UserTitle =>
|
||||
UserLogin: :login,
|
||||
UserPw: :password,
|
||||
};
|
||||
|
||||
result.each { |user|
|
||||
# puts 'USER: ' + user.inspect
|
||||
_set_valid(user)
|
||||
_set_valid(user)
|
||||
|
||||
role = Role.lookup( name: 'Agent' )
|
||||
# get new attributes
|
||||
user_new = {
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1,
|
||||
source: 'OTRS Import',
|
||||
role_ids: [ role.id ],
|
||||
}
|
||||
map.each { |key, value|
|
||||
if user[key.to_s]
|
||||
user_new[value] = user[key.to_s]
|
||||
end
|
||||
}
|
||||
role = Role.lookup( name: 'Agent' )
|
||||
# get new attributes
|
||||
user_new = {
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1,
|
||||
source: 'OTRS Import',
|
||||
role_ids: [ role.id ],
|
||||
}
|
||||
map.each { |key, value|
|
||||
if user[key.to_s]
|
||||
user_new[value] = user[key.to_s]
|
||||
end
|
||||
}
|
||||
|
||||
# check if state already exists
|
||||
# user_old = User.where( :login => user_new[:login] ).first
|
||||
user_old = User.where( id: user_new[:id] ).first
|
||||
# check if state already exists
|
||||
user_old = User.where( id: user_new[:id] ).first
|
||||
|
||||
# set state types
|
||||
if user_old
|
||||
puts "update User.find(#{user_new[:id]})"
|
||||
# puts 'Update User' + user_new.inspect
|
||||
user_new.delete( :role_ids )
|
||||
user_old.update_attributes(user_new)
|
||||
else
|
||||
puts "add User.find(#{user_new[:id]})"
|
||||
# puts 'Add User' + user_new.inspect
|
||||
user = User.new(user_new)
|
||||
user.id = user_new[:id]
|
||||
user.save
|
||||
end
|
||||
|
||||
# end
|
||||
if user_old
|
||||
puts "update User.find(#{user_new[:id]})"
|
||||
# puts 'Update User' + user_new.inspect
|
||||
user_new.delete( :role_ids )
|
||||
user_old.update_attributes(user_new)
|
||||
else
|
||||
puts "add User.find(#{user_new[:id]})"
|
||||
# puts 'Add User' + user_new.inspect
|
||||
user = User.new(user_new)
|
||||
user.id = user_new[:id]
|
||||
user.save
|
||||
end
|
||||
}
|
||||
end
|
||||
def self.customer
|
||||
|
@ -767,7 +763,6 @@ module Import::OTRS
|
|||
UserEmail: :email,
|
||||
UserFirstname: :firstname,
|
||||
UserLastname: :lastname,
|
||||
# :UserTitle =>
|
||||
UserLogin: :login,
|
||||
UserPassword: :password,
|
||||
UserPhone: :phone,
|
||||
|
@ -800,7 +795,7 @@ module Import::OTRS
|
|||
}
|
||||
|
||||
# check if state already exists
|
||||
# user_old = User.where( :login => user_new[:login] ).first
|
||||
# user_old = User.where( :login => user_new[:login] ).first
|
||||
user_old = User.where( login: user_new[:login] ).first
|
||||
|
||||
# set state types
|
||||
|
@ -819,17 +814,17 @@ module Import::OTRS
|
|||
end
|
||||
def self._set_valid(record)
|
||||
# map
|
||||
if record['ValidID'] == '3'
|
||||
record['ValidID'] = '2'
|
||||
end
|
||||
if record['ValidID'] == '2'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
if record['ValidID'] == '1'
|
||||
record['ValidID'] = true
|
||||
end
|
||||
if record['ValidID'] == '0'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
if record['ValidID'] == '3'
|
||||
record['ValidID'] = '2'
|
||||
end
|
||||
if record['ValidID'] == '2'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
if record['ValidID'] == '1'
|
||||
record['ValidID'] = true
|
||||
end
|
||||
if record['ValidID'] == '0'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -346,14 +346,14 @@ module Import::OTRS2
|
|||
steps = 30
|
||||
run = true
|
||||
while run
|
||||
count += steps
|
||||
records = load('CustomerUser', steps, count - steps)
|
||||
if !records || !records[0]
|
||||
log 'all customers imported.'
|
||||
run = false
|
||||
next
|
||||
end
|
||||
customer(records, organizations)
|
||||
count += steps
|
||||
records = load('CustomerUser', steps, count - steps)
|
||||
if !records || !records[0]
|
||||
log 'all customers imported.'
|
||||
run = false
|
||||
next
|
||||
end
|
||||
customer(records, organizations)
|
||||
end
|
||||
|
||||
Thread.abort_on_exception = true
|
||||
|
@ -944,7 +944,6 @@ module Import::OTRS2
|
|||
UserEmail: :email,
|
||||
UserFirstname: :firstname,
|
||||
UserLastname: :lastname,
|
||||
# :UserTitle =>
|
||||
UserLogin: :login,
|
||||
UserPw: :password,
|
||||
};
|
||||
|
@ -1065,7 +1064,6 @@ module Import::OTRS2
|
|||
UserEmail: :email,
|
||||
UserFirstname: :firstname,
|
||||
UserLastname: :lastname,
|
||||
# :UserTitle =>
|
||||
UserLogin: :login,
|
||||
UserPassword: :password,
|
||||
UserPhone: :phone,
|
||||
|
@ -1236,20 +1234,20 @@ module Import::OTRS2
|
|||
|
||||
def self._set_valid(record)
|
||||
|
||||
# map
|
||||
if record['ValidID'].to_s == '3'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '2'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '1'
|
||||
record['ValidID'] = true
|
||||
elsif record['ValidID'].to_s == '0'
|
||||
record['ValidID'] = false
|
||||
# map
|
||||
if record['ValidID'].to_s == '3'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '2'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '1'
|
||||
record['ValidID'] = true
|
||||
elsif record['ValidID'].to_s == '0'
|
||||
record['ValidID'] = false
|
||||
|
||||
# fallback
|
||||
else
|
||||
record['ValidID'] = true
|
||||
end
|
||||
# fallback
|
||||
else
|
||||
record['ValidID'] = true
|
||||
end
|
||||
end
|
||||
|
||||
# cleanup invalid values
|
||||
|
|
|
@ -22,7 +22,7 @@ class Sessions::Backend::ActivityStream
|
|||
|
||||
# update last changed
|
||||
if activity_stream && activity_stream.first
|
||||
@last_change = activity_stream.first['created_at']
|
||||
@last_change = activity_stream.first['created_at']
|
||||
end
|
||||
|
||||
@user.activity_stream( 25, true )
|
||||
|
|
|
@ -22,11 +22,11 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
|||
time_diff = 0
|
||||
if timezone
|
||||
begin
|
||||
time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset
|
||||
rescue Exception => e
|
||||
puts "ERROR: Can't fine tomezone #{timezone}"
|
||||
puts e.inspect
|
||||
puts e.backtrace
|
||||
time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset
|
||||
rescue Exception => e
|
||||
puts "ERROR: Can't fine tomezone #{timezone}"
|
||||
puts e.inspect
|
||||
puts e.backtrace
|
||||
end
|
||||
end
|
||||
beginning_of_workday = Time.parse("1977-10-27 #{config['beginning_of_workday']}")
|
||||
|
@ -169,7 +169,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
|||
diff = end_time - start_time
|
||||
|
||||
if diff > 59 * 60
|
||||
diff = start_time - start_time.beginning_of_hour
|
||||
diff = start_time - start_time.beginning_of_hour
|
||||
end
|
||||
start_time += diff
|
||||
|
||||
|
|
Loading…
Reference in a new issue