From nobody@FreeBSD.org  Thu Apr  5 08:14:17 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0AB77106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Apr 2012 08:14:17 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id EA20B8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Apr 2012 08:14:16 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q358EGjU045439
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 5 Apr 2012 08:14:16 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q358EG9E045423;
	Thu, 5 Apr 2012 08:14:16 GMT
	(envelope-from nobody)
Message-Id: <201204050814.q358EG9E045423@red.freebsd.org>
Date: Thu, 5 Apr 2012 08:14:16 GMT
From: Veselin Slavov <vess@slavof.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: www/asterisk-stat - pgsql select substring() problem
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: jfkimura@yahoo.co.jp

>Number:         166662
>Category:       ports
>Synopsis:       www/asterisk-stat - pgsql select substring() problem
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    scheidell
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 05 08:20:08 UTC 2012
>Closed-Date:    Thu Jun 07 22:00:45 UTC 2012
>Last-Modified:  Sat Jun  9 11:20:08 UTC 2012
>Originator:     Veselin Slavov
>Release:        7.4-STABLE
>Organization:
>Environment:
FreeBSD server.slavof.net 7.4-STABLE FreeBSD 7.4-STABLE #57: Mon Mar 12 14:33:42 EET 2012     vess@server.slavof.net:/usr/obj/usr/src/sys/server  i386
>Description:
PG_VERSION = 9.0

While using statustics page for 'cdr report', 'RED TOTAL BAR TABLE' at the bottom not displayed. 

Here is part of  /var/log/message:

Apr  5 10:22:37 server postgres[34881]: [2-1] ERROR:  function pg_catalog.substring(timestamp with time zone, integer, integer) does not exist at character 8
Apr  5 10:22:37 server postgres[34881]: [2-2] HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
Apr  5 10:22:37 server postgres[34881]: [2-3] STATEMENT:  SELECT substring(calldate,1,10) AS day, sum(duration) AS calltime, count(*) as nbcall FROM cdr WHERE (calldate) >= ('2012-01-01') AND (calldate) <= ('2012-03-31 23:59:59') GROUP BY substring(calldate,1,10)
>How-To-Repeat:
http://127.0.0.1/asterisk-stat/cdr.php?s=1

Choose any period and click search.

>Fix:
patch file attached

Patch attached with submission follows:

--- call-log.php.orig	2012-04-05 10:48:18.000000000 +0300
+++ call-log.php	2012-04-05 10:48:29.000000000 +0300
@@ -229,7 +229,7 @@
 	
 	
 	/************************/
-	$QUERY = "SELECT substring(calldate,1,10) AS day, sum(duration) AS calltime, count(*) as nbcall FROM cdr WHERE ".$FG_TABLE_CLAUSE." GROUP BY substring(calldate,1,10)"; //extract(DAY from calldate) 
+	$QUERY = "SELECT substr(cast(calldate as text),1,10) AS day, sum(duration) AS calltime, count(*) as nbcall FROM cdr WHERE ".$FG_TABLE_CLAUSE." GROUP BY substr(cast(calldate as text),1,10)"; //extract(DAY from calldate) 
 	//echo "$QUERY";
 	
 	


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-www->freebsd-ports-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Apr 5 08:56:54 UTC 2012 
Responsible-Changed-Why:  
ports PR.  The 'www' category is for problems with the FreeBSD.org 
website. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166662 

From: Veselin Slavov <vess@slavof.net>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: www/166662: www/asterisk-stat - pgsql select substring() problem
Date: Thu, 05 Apr 2012 11:55:28 +0300

 Even better - optimized query with order:
 
 $QUERY = "SELECT cast(calldate as date) AS day, sum(duration) AS
 calltime, count(*) as nbcall FROM cdr WHERE ".$FG_TABLE_CLAUSE." GROUP
 BY cast(calldate as date) order by 1 desc"; //extract(DAY from calldate)

From: Michael Scheidell <scheidell@freebsd.org>
To: <jfkimura@yahoo.co.jp>, <bug-followup@FreeBSD.ORG>
Cc:  
Subject: Re: ports/166662: www/asterisk-stat - pgsql select substring() problem
Date: Tue, 1 May 2012 16:51:53 -0400

 --------------090200090407060906080306
 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Maintainer:
 I am assuming you didn't get a copy of this, due to the original 
 submitters mistaken category.
 
 Please check this patch, and decide if you want to approve it.
 I would suggest a PORTREVISION bump (at least), and if this patch is 
 needed, send it upstream?
 
 -- 
 Michael Scheidell, CTO
  >*| * SECNAP Network Security Corporation
 d: +1.561.948.2259
 w: http://people.freebsd.org/~scheidell
 
 --------------090200090407060906080306
 Content-Type: text/html; charset="ISO-8859-1"
 Content-Transfer-Encoding: 7bit
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>
 
     <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   </head>
   <body bgcolor="#ffffff" text="#000000">
     Maintainer: <br>
     I am assuming you didn't get a copy of this, due to the original
     submitters mistaken category.<br>
     <br>
     Please check this patch, and decide if you want to approve it.<br>
     I would suggest a PORTREVISION bump (at least), and if this patch is
     needed, send it upstream?<br>
     <br>
     <div class="moz-signature">-- <br>
       Michael Scheidell, CTO<br>
       <font color="#999999">&gt;</font><font color="#cc0000"> <b>| </b></font>
       SECNAP Network Security Corporation<br>
       d: +1.561.948.2259<br>
       w: <a class="moz-txt-link-freetext" href="http://people.freebsd.org/~scheidell">http://people.freebsd.org/~scheidell</a>
     </div>
   </body>
 </html>
 
 --------------090200090407060906080306--
Responsible-Changed-From-To: freebsd-ports-bugs->scheidell 
Responsible-Changed-By: scheidell 
Responsible-Changed-When: Sat May 26 11:39:26 UTC 2012 
Responsible-Changed-Why:  
I'll take it. Maintainer feedback timeout. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166662 

From: Michael Scheidell <scheidell@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/166662: www/asterisk-stat - pgsql select
 substring() problem
Date: Sat, 26 May 2012 07:57:04 -0400 (EDT)

 --ELM1338033424-67568-0_
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain; charset="US-ASCII"
 
 For audit, could everyone please test the attached patch? 
 
 (curl 'http://www.freebsd.org/cgi/query-pr.cgi?pr=ports%2F166662&getpatch=2' | patch -EuNI)
 
 Veselin: to avoid confusion, this appears to apply your second QUERY.
 jfkimura:  do you approve this patch?
 
 (note, I did bump PORTREVISION, this will force a rebuild for mysql as well as pgsql users, but it looks like this is the 
 safest thing to do)
 
 -- 
 Michael Scheidell, CTO
 SECNAP Network Security Corporation
 http://people.freebsd.org/~scheidell
 
 ______________________________________________________________________
 This email has been scanned and certified safe by SpammerTrap(r). 
 For Information please see http://www.spammertrap.com/
 ______________________________________________________________________  
   
 --ELM1338033424-67568-0_
 Content-Transfer-Encoding: 7bit
 Content-Type: text/x-patch
 Content-Disposition: attachment; filename="www_askrisk-stat.patch"
 
 Index: Makefile
 ===================================================================
 RCS file: /home/pcvs/ports/www/asterisk-stat/Makefile,v
 retrieving revision 1.13
 diff -u -r1.13 Makefile
 --- Makefile	14 Sep 2011 21:42:04 -0000	1.13
 +++ Makefile	26 May 2012 11:52:41 -0000
 @@ -7,7 +7,7 @@
  
  PORTNAME=	asterisk-stat
  PORTVERSION=	2.0.1
 -PORTREVISION=	10
 +PORTREVISION=	11
  CATEGORIES=	www
  MASTER_SITES=	http://www.areski.net/${SITE_SUBDIR}/
  DISTNAME=	${PORTNAME}-v${PORTVERSION:S/./_/g}
 @@ -32,6 +32,7 @@
  
  .if defined(WITH_PGSQL)
  ASTERISKSTATDB=	pgsql
 +EXTRA_PATCHES+=	${FILESDIR}/pgsql__patch-call.log.php
  .else
  ASTERISKSTATDB=	mysql
  RUN_DEPENDS+=	${LOCALBASE}/lib/asterisk/modules/cdr_addon_mysql.so:${PORTSDIR}/net/asterisk16-addons
 Index: files/pgsql__patch-call.log.php
 ===================================================================
 RCS file: files/pgsql__patch-call.log.php
 diff -N files/pgsql__patch-call.log.php
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ files/pgsql__patch-call.log.php	26 May 2012 11:52:41 -0000
 @@ -0,0 +1,9 @@
 +--- call-log.php.orig	2012-04-05 10:48:18.000000000 +0300
 ++++ call-log.php	2012-04-05 10:48:29.000000000 +0300
 +@@ -229,7 +229,7 @@
 + 	
 + 	
 + 	/************************/
 +-	$QUERY = "SELECT substring(calldate,1,10) AS day, sum(duration) AS calltime, count(*) as nbcall FROM cdr WHERE ".$FG_TABLE_CLAUSE." GROUP BY substring(calldate,1,10)"; //extract(DAY from calldate) 
 ++	$QUERY = "SELECT cast(calldate as date) AS day, sum(duration) AS calltime, count(*) as nbcall FROM cdr WHERE ".$FG_TABLE_CLAUSE." GROUP BY cast(calldate as date) order by 1 desc"; //extract(DAY from calldate)
 + 	//echo "$QUERY";
 
 --ELM1338033424-67568-0_--
State-Changed-From-To: open->feedback 
State-Changed-By: scheidell 
State-Changed-When: Sun May 27 10:13:40 UTC 2012 
State-Changed-Why:  
Ask for maintainer approval. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166662 
State-Changed-From-To: feedback->closed 
State-Changed-By: scheidell 
State-Changed-When: Thu Jun 7 22:00:42 UTC 2012 
State-Changed-Why:  
No response. Don't know what submitter or maintainer wants to do. 
Closeing pr. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166662 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/166662: commit references a PR
Date: Sat,  9 Jun 2012 11:11:00 +0000 (UTC)

 scheidell    2012-06-09 11:10:50 UTC
 
   FreeBSD ports repository
 
   Modified files:
     www/asterisk-stat    Makefile 
   Added files:
     www/asterisk-stat/files pgsql__patch-call.log.php 
   Log:
   - Fix pgsql select substring() problem
   - pet portlint (gd.4 to gd.[4-9] in LIB_DEPENDS)
   - Bump PORTREVISION
   
   PR:             ports/166662
   Submitted by:   Veselin Slavov <vess@slavof.net>
   Reviewed by:    scheidell@ (me)
   Approved by:    F. Kimura <jfkimura@yahoo.co.jp> (maintainer)
   
   Revision  Changes    Path
   1.15      +3 -2      ports/www/asterisk-stat/Makefile
   1.1       +9 -0      ports/www/asterisk-stat/files/pgsql__patch-call.log.php (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: Michael Scheidell <scheidell@FreeBSD.org>
To: <bug-followup@FreeBSD.org>
Cc:  
Subject: Fwd: Re: ports/166662: www/asterisk-stat - pgsql select substring()
 problem
Date: Sat, 9 Jun 2012 07:11:22 -0400

 -------- Original Message --------
 Subject: 	Re: ports/166662: www/asterisk-stat - pgsql select substring() 
 problem
 Date: 	Sat, 9 Jun 2012 16:04:48 +0900
 From: 	F. Kimura <jfkimura@yahoo.co.jp>
 Reply-To: 	F. Kimura <jfkimura@yahoo.co.jp>
 To: 	scheidell@FreeBSD.org <scheidell@FreeBSD.org>, vess@slavof.net 
 <vess@slavof.net>
 
 
 
 I was not using e-mail for a month. Sorry. If possible, I want to accept this PR.
 
 // Fumihiko Kimura
 
 
 
>Unformatted:
