Improved code layout.

This commit is contained in:
Martin Edenhofer 2016-11-06 16:46:36 +01:00
parent db2b329331
commit 15a23f3723
3 changed files with 11 additions and 11 deletions

View file

@ -13,15 +13,15 @@ class _globalSearchSingleton extends Spine.Module
@apiPath = App.Config.get('api_path') @apiPath = App.Config.get('api_path')
execute: (params) -> execute: (params) ->
query = params.query query = params.query
render = params.render render = params.render
limit = params.limit || 10 limit = params.limit || 10
cache_key = query + '_' + limit cacheKey = "#{query}_#{limit}"
# use cache for search result # use cache for search result
currentTime = new Date currentTime = new Date
if @searchResultCache[cache_key] && @searchResultCache[cache_key].time > currentTime.setSeconds(currentTime.getSeconds() - 20) if @searchResultCache[cacheKey] && @searchResultCache[cacheKey].time > currentTime.setSeconds(currentTime.getSeconds() - 20)
render(@searchResultCache[cache_key].result) render(@searchResultCache[cacheKey].result)
return return
App.Ajax.request( App.Ajax.request(
@ -49,11 +49,11 @@ class _globalSearchSingleton extends Spine.Module
App.Log.error('_globalSearchSingleton', "No such model App.#{item.type}") App.Log.error('_globalSearchSingleton', "No such model App.#{item.type}")
diff = false diff = false
if @searchResultCache[cache_key] if @searchResultCache[cacheKey]
diff = difference(@searchResultCache[cache_key].resultRaw, data.result) diff = difference(@searchResultCache[cacheKey].resultRaw, data.result)
# cache search result # cache search result
@searchResultCache[cache_key] = @searchResultCache[cacheKey] =
result: result result: result
resultRaw: data.result resultRaw: data.result
limit: limit limit: limit

View file

@ -14,7 +14,7 @@
<thead> <thead>
<tr> <tr>
<th><%- @T('Name') %></th> <th><%- @T('Name') %></th>
<th><%- @T('Permission') %></th> <th><%- @T('Permissions') %></th>
<th><%- @T('Created') %></th> <th><%- @T('Created') %></th>
<th><%- @T('Expires') %></th> <th><%- @T('Expires') %></th>
<th><%- @T('Last used') %></th> <th><%- @T('Last used') %></th>

View file

@ -47,7 +47,7 @@ returns
def fetch (options, channel, check_type = '', verify_string = '') def fetch (options, channel, check_type = '', verify_string = '')
ssl = true ssl = true
port = 995 port = 995
if options.key?(:ssl) && options[:ssl].to_s == 'false' if options.key?(:ssl) && options[:ssl] == false
ssl = false ssl = false
port = 110 port = 110
end end