Skip to content

Commit a61f857

Browse files
committed
fixed reporting grouping for mysql
1 parent fb36668 commit a61f857

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>Time Tracker</name>
66
<summary>Time Tracker App</summary>
77
<description><![CDATA[Time Tracker App]]></description>
8-
<version>0.0.30</version>
8+
<version>0.0.31</version>
99
<licence>agpl</licence>
1010
<author mail="[email protected]" >MTier Ltd.</author>
1111
<namespace>TimeTracker</namespace>

lib/Db/ReportItemMapper.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public function __construct(IDBConnection $db) {
3434
public function report($user, $from, $to, $filterProjectId, $filterClientId, $filterTagId, $timegroup, $groupOn1, $groupOn2, $admin, $start, $limit ){
3535

3636
$selectFields = ['min(wi.id) as id', 'sum(duration) as "totalDuration"'];
37+
38+
$pg = 0;
3739
if ($this->dbengine != 'MYSQL') {
40+
$pg = 1;
3841
if(empty($timegroup)){
3942
$selectFields[]= "to_timestamp(min(start))::date as time";
4043
} elseif ($timegroup == 'week') {
@@ -173,14 +176,22 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
173176
if ($groupOn1 == 'name'){
174177
$groups[] = 'wi.name';
175178
} else {
176-
$groups[] = '"'.$groupOn1.'"';
179+
if($pg) { // postgres needs quotes on names
180+
$groups[] = '"'.$groupOn1.'"';
181+
} else {
182+
$groups[] = $groupOn1;
183+
}
177184
}
178185
if (!empty($groupOn2)){
179186
if ($groupOn2 == "project" || $groupOn2 == "client" || $groupOn2 == "name" || $groupOn2 == "userUid"){
180187
if ($groupOn2 == 'name'){
181188
$groups[] = 'wi.name';
182189
} else {
183-
$groups[] = '"'.$groupOn2.'"';
190+
if($pg) {
191+
$groups[] = '"'.$groupOn2.'"';// postgres needs quotes on names
192+
} else {
193+
$groups[] = $groupOn2;
194+
}
184195
}
185196
}
186197
}
@@ -195,8 +206,8 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
195206
$limit = 10000;
196207
}
197208
$sql = 'SELECT '.$selectItems.' where '.implode(" and ",$filters).' '.$group. ' order by time desc';
198-
//var_dump($sql);
199-
//var_dump($params);
209+
// var_dump($sql);
210+
// var_dump($params);
200211
return $this->findEntities($sql, $params, $limit, $start);
201212
}
202213

0 commit comments

Comments
 (0)