Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2015-10-20 12:52:51 +02:00
commit 6ba881a327
2 changed files with 18 additions and 47 deletions

View file

@ -23,9 +23,9 @@ class ReportsController < ApplicationController
created = aggs(start, stop, 'minute', 'created_at')
closed = aggs(start, stop, 'minute', 'close_time')
elsif params[:timeRange] == 'day'
start = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").iso8601
start = "#{start}T00:00:00Z"
stop = "#{start}T23:59:59Z"
date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").to_s
start = "#{date}T00:00:00Z"
stop = "#{date}T23:59:59Z"
created = aggs(start, stop, 'hour', 'created_at')
closed = aggs(start, stop, 'hour', 'close_time')
elsif params[:timeRange] == 'week'
@ -61,9 +61,9 @@ class ReportsController < ApplicationController
start = (Time.zone.now - 60.minutes).iso8601
stop = Time.zone.now.iso8601
elsif params[:timeRange] == 'day'
start = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").iso8601
start = "#{start}T00:00:00Z"
stop = "#{start}T23:59:59Z"
date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").to_s
start = "#{date}T00:00:00Z"
stop = "#{date}T23:59:59Z"
elsif params[:timeRange] == 'week'
start = Date.commercial(params[:year], params[:week]).iso8601
stop = Date.parse(start).end_of_week
@ -86,10 +86,14 @@ class ReportsController < ApplicationController
end
def aggs(range_start, range_end, interval, field)
interval_es = interval
if interval == 'week'
interval_es = 'day'
end
result = SearchIndexBackend.aggs(
{
},
[range_start, range_end, field, interval],
[range_start, range_end, field, interval_es],
['Ticket'],
)
data = []
@ -119,12 +123,13 @@ class ReportsController < ApplicationController
end
next if !item['doc_count']
next if item['key_as_string'] !~ /#{start_string}/
next if match
match = true
data.push [counter, item['doc_count']]
if interval == 'month'
start = start.next_month
elsif interval == 'week'
start = start.next_week
start = start.next_day
elsif interval == 'day'
start = start.next_day
elsif interval == 'hour'
@ -138,7 +143,7 @@ class ReportsController < ApplicationController
if interval == 'month'
start = start.next_month
elsif interval == 'week'
start = start.next_week
start = start.next_day
elsif interval == 'day'
start = start + 1.day
elsif interval == 'hour'

View file

@ -10,6 +10,9 @@ class CreateReport < ActiveRecord::Migration
end
add_index :report_profiles, [:name], unique: true
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Report::Profile.create_if_not_exists(
name: '-all-',
condition: {},
@ -17,44 +20,7 @@ class CreateReport < ActiveRecord::Migration
updated_by_id: 1,
created_by_id: 1,
)
Role.create_if_not_exists( name: 'Report', created_by_id: 1, updated_by_id: 1 )
Translation.create_if_not_exists(
locale: 'de-de',
source: 'Ticket Count',
target: 'Ticket Anzahl',
updated_by_id: 1,
created_by_id: 1,
)
Translation.create_if_not_exists(
locale: 'de-de',
source: 'Ticket Count',
target: 'Ticket Anzahl',
updated_by_id: 1,
created_by_id: 1,
)
Translation.create_if_not_exists(
locale: 'de-de',
source: 'Create Channels',
target: 'Erstellkanäle',
updated_by_id: 1,
created_by_id: 1,
)
Translation.create_if_not_exists(
locale: 'de-de',
source: 'Times',
target: 'Zeiten',
updated_by_id: 1,
created_by_id: 1,
)
Translation.create_if_not_exists(
locale: 'de-de',
source: 'Communication',
target: 'Kommunikation',
updated_by_id: 1,
created_by_id: 1,
)
Role.create_if_not_exists(name: 'Report', created_by_id: 1, updated_by_id: 1)
end
def down