@@ -37,7 +37,6 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
3737
3838 $ selectFields = ['min(wi.id) as id ' , 'sum(duration) as "totalDuration" ' ];
3939
40- $ pg = 0 ;
4140 $ aggregation = true ;
4241 if (empty ($ groupOn1 ) && empty ($ groupOn2 ) && empty ($ timegroup )) {
4342 $ selectFields [] = 'min(wi.details) as "details" ' ;
@@ -60,37 +59,10 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
6059 } else {
6160 $ selectFields []= "min(start) as time " ;
6261 }
63- } elseif ( $ timegroup == ' day ' ) {
62+ } else {
6463 $ selectFields []= "start as time " ;
6564 }
6665
67- if ($ this ->dbengine == 'POSTGRES ' ) {
68- $ pg = 1 ;
69- if ($ timegroup == 'week ' ) {
70- $ selectFields []= "concat(date_part('year', to_timestamp(start)), 'W', to_char(to_timestamp(start), 'IW')) as time " ;
71- }elseif ($ timegroup == 'year ' ) {
72- $ selectFields []= "date_part('year', to_timestamp(start)) as time " ;
73- }elseif ($ timegroup == 'month ' ) {
74- $ selectFields []= "to_char(to_timestamp(start), 'YYYY-MM') as time " ;
75- }
76- } else if ($ this ->dbengine == 'SQLITE ' ) {
77- if ($ timegroup == 'week ' ) {
78- $ selectFields []= "strftime('%YW%W', datetime(start, 'unixepoch')) as time " ;
79- }elseif ($ timegroup == 'year ' ) {
80- $ selectFields []= "strftime('%Y', datetime(start, 'unixepoch')) as time " ;
81- }elseif ($ timegroup == 'month ' ) {
82- $ selectFields []= "strftime('%Y-%m', datetime(start, 'unixepoch')) as time " ;
83- }
84- } else {
85- if ($ timegroup == 'week ' ) {
86- $ selectFields []= "CONCAT(YEAR(FROM_UNIXTIME(start)), 'W', WEEK(FROM_UNIXTIME(start))) as time " ;
87- }elseif ($ timegroup == 'year ' ) {
88- $ selectFields []= "YEAR(FROM_UNIXTIME(start)) as time " ;
89- }elseif ($ timegroup == 'month ' ) {
90- $ selectFields []= "DATE_FORMAT(FROM_UNIXTIME(start),'%Y-%m') as time " ;
91- }
92-
93- }
9466 if ($ aggregation ){
9567 if ($ groupOn1 != 'name ' ){
9668 if ($ this ->dbengine != 'MYSQL ' ) {
@@ -213,7 +185,7 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
213185 if ($ groupOn1 == 'name ' ){
214186 $ groups [] = 'wi.name ' ;
215187 } else {
216- if ( $ pg ) { // postgres needs quotes on names
188+ if ( $ this -> dbengine == ' POSTGRES ' ) { // postgres needs quotes on names
217189 $ groups [] = '" ' .$ groupOn1 .'" ' ;
218190 } else {
219191 $ groups [] = $ groupOn1 ;
@@ -225,8 +197,8 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
225197 if ($ groupOn2 == 'name ' ){
226198 $ groups [] = 'wi.name ' ;
227199 } else {
228- if ( $ pg ) {
229- $ groups [] = '" ' .$ groupOn2 .'" ' ;// postgres needs quotes on names
200+ if ( $ this -> dbengine == ' POSTGRES ' ) { // postgres needs quotes on names
201+ $ groups [] = '" ' .$ groupOn2 .'" ' ;
230202 } else {
231203 $ groups [] = $ groupOn2 ;
232204 }
0 commit comments