From 2137250bae371de083e46e8af08d2c1b3ac27b96 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 1 Jun 2016 08:21:50 +0200 Subject: [PATCH] Fixed postgresql ERROR: date/time field value out of range: "2016-6-31" issue. --- app/controllers/reports_controller.rb | 7 ++++--- lib/report/article_by_type_sender.rb | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 8d9893952..9dbf0d2a8 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -159,9 +159,10 @@ class ReportsController < ApplicationController stop = Date.parse(start).end_of_month range = 'day' else - start = "#{params[:year]}-01-01" - stop = "#{params[:year]}-12-31" - range = 'month' + start = "#{params[:year]}-01-01" + stop_date = Date.parse(day_start).end_of_month + stop = "#{stop_date.year}-#{stop_date.month}-#{stop_date.day}" + range = 'month' end { profile: profile, diff --git a/lib/report/article_by_type_sender.rb b/lib/report/article_by_type_sender.rb index 01520e357..c79a8457d 100644 --- a/lib/report/article_by_type_sender.rb +++ b/lib/report/article_by_type_sender.rb @@ -56,8 +56,8 @@ returns stop = start + 1.minute end query, bind_params, tables = Ticket.selector2sql(params[:selector]) - sender = Ticket::Article::Sender.lookup( name: params[:params][:sender] ) - type = Ticket::Article::Type.lookup( name: params[:params][:type] ) + sender = Ticket::Article::Sender.lookup(name: params[:params][:sender]) + type = Ticket::Article::Type.lookup(name: params[:params][:type]) count = Ticket::Article.joins('INNER JOIN tickets ON tickets.id = ticket_articles.ticket_id') .where(query, *bind_params).joins(tables) .where(