Small code cleanup.

This commit is contained in:
Martin Edenhofer 2017-11-21 15:25:04 +01:00
parent 9f204806db
commit 460182e663
10 changed files with 18 additions and 21 deletions

View file

@ -685,8 +685,8 @@ class App.Sidebar extends App.Controller
for item in @items
area = localEl.filter('.sidebar[data-tab="' + item.name + '"]')
if item.callback
item.callback( area.find('.sidebar-content') )
if item.actions
item.callback(area.find('.sidebar-content'))
if !_.isEmpty(item.actions)
new App.ActionRow(
el: area.find('.js-actions')
items: item.actions

View file

@ -71,7 +71,7 @@ class TwitterReply
exclude = true
# exclude own screen_name
if recipientScreenName is "@#{@ticket.preferences.channel_screen_name}".toLowerCase()
if recipientScreenName is "@#{ticket.preferences.channel_screen_name}".toLowerCase()
exclude = true
if exclude is false

View file

@ -70,6 +70,7 @@ class App.TicketStats extends App.Controller
render: (data) =>
if !data
data = @data
return if !data
user_total = 0
if data.user.open_ids && data.user.closed_ids

View file

@ -40,7 +40,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
if channel.status_in == 'error'
message = "Channel: #{channel.area} in "
%w(host user uid).each do |key|
next if !channel.options[key] || channel.options[key].empty?
next if channel.options[key].blank?
message += "key:#{channel.options[key]};"
end
issues.push "#{message} #{channel.last_log_in}"
@ -53,7 +53,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
next if channel.status_out != 'error'
message = "Channel: #{channel.area} out "
%w(host user uid).each do |key|
next if !channel.options[key] || channel.options[key].empty?
next if channel.options[key].blank?
message += "key:#{channel.options[key]};"
end
issues.push "#{message} #{channel.last_log_out}"
@ -89,7 +89,7 @@ curl http://localhost/api/v1/monitoring/health_check?token=XXX
token = Setting.get('monitoring_token')
if issues.empty?
if issues.blank?
result = {
healthy: true,
message: 'success',

View file

@ -45,10 +45,10 @@ class UserAccessTokenController < ApplicationController
if Setting.get('api_token_access') == false
raise Exceptions::UnprocessableEntity, 'API token access disabled!'
end
if params[:label].empty?
if params[:label].blank?
raise Exceptions::UnprocessableEntity, 'Need label!'
end
token = Token.create(
token = Token.create!(
action: 'api',
label: params[:label],
persistent: true,
@ -66,7 +66,7 @@ class UserAccessTokenController < ApplicationController
def destroy
token = Token.find_by(action: 'api', user_id: current_user.id, id: params[:id])
raise Exceptions::UnprocessableEntity, 'Unable to find api token!' if !token
token.destroy
token.destroy!
render json: {}, status: :ok
end

View file

@ -615,10 +615,10 @@ returns
if channel[:group_id]
group = Group.lookup(id: channel[:group_id])
end
if !group || group && !group.active
if group.blank? || group.active == false
group = Group.where(active: true).order('id ASC').first
end
if !group
if group.blank?
group = Group.first
end
title = mail[:subject]

View file

@ -44,7 +44,7 @@ returns:
logger.error "File #{file['location']} is different"
issues[file['location']] = 'changed'
end
return nil if issues.empty?
return nil if issues.blank?
issues
end

View file

@ -1031,9 +1031,7 @@ perform changes on ticket
if key == 'ticket.action'
next if value['value'].blank?
next if value['value'] != 'delete'
destroy
destroy!
next
end

View file

@ -13,7 +13,6 @@ module Enrichment
def synced?
return false if !@config
# TODO
UserInfo.current_user_id = 1
return false if !mapping?
@ -74,7 +73,7 @@ module Enrichment
return false if @user.organization_id
# can't create organization without name
return false if @current_changes[:name].empty?
return false if @current_changes[:name].blank?
organization = create_current
@ -95,7 +94,7 @@ module Enrichment
object: organization,
current_changes: @current_changes,
)
organization.save
organization.save!
ExternalSync.create(
source: @source,
@ -127,10 +126,10 @@ module Enrichment
)
organization.updated_by_id = 1
organization.save
organization.save!
@external_organization.last_payload = @payload
@external_organization.save
@external_organization.save!
organization
end

View file

@ -12,7 +12,6 @@ module Enrichment
return false if !@config
return false if @local_user.email.blank?
# TODO
UserInfo.current_user_id = 1
return false if !mapping?