commit/mtrack: 4 new changesets

0 views
Skip to first unread message

Bitbucket

unread,
Apr 24, 2012, 9:41:02 AM4/24/12
to mtr...@googlegroups.com
4 new commits in mtrack:


https://bitbucket.org/wez/mtrack/changeset/1cb4b3f480f4/
changeset: 1cb4b3f480f4
user: wez
date: 2012-04-24 15:06:18
summary: fixup the remaining effort calculation.
This is so complex that it is itching for a rewrite :-/
affected #: 2 files

diff -r 230c7682b57252b004d1beb68e3999e62583a8c7 -r 1cb4b3f480f4e2a97133a7d5116625cdbd55e91e inc/issue.php
--- a/inc/issue.php
+++ b/inc/issue.php
@@ -1712,20 +1712,25 @@
}
}

+ // This is much more complex than I'd like it to be :-/
+ // This logic MUST be equivalent to that of the 'remaining' field
+ // in inc/report.php.
function getRemaining() {
if ($this->status == 'closed') {
return 0;
}
foreach (MTrackDB::q(<<<SQL
-SELECT coalesce(
- case when sum(remaining) < 0 then 0 else
- round(cast(sum(remaining) as numeric), 2)
- end, ?)
- from effort where tid = ?
+SELECT
+ count(remaining),
+ round(cast(coalesce(sum(remaining), ?) as numeric), 2)
+FROM effort where tid = ? and remaining != 0
SQL
, $this->estimated, $this->tid
)->fetchAll() as $row) {
- return $row[0] == 0 ? 0 : $row[0];
+ if ($row[0]) {
+ /* normalize floating point zero to precisely zero */
+ return $row[1] == 0 ? 0 : $row[1];
+ }
}
return $this->estimated;
}


diff -r 230c7682b57252b004d1beb68e3999e62583a8c7 -r 1cb4b3f480f4e2a97133a7d5116625cdbd55e91e inc/report.php
--- a/inc/report.php
+++ b/inc/report.php
@@ -569,7 +569,26 @@
tk left join keywords k on (tk.kid = k.kid)
where tk.tid = t.tid) as keyword',
'type' => 'classification as type',
- 'remaining' => "(case when t.status = 'closed' then 0 else (select coalesce(case when sum(remaining) < 0 then 0 else round(cast(sum(remaining) as numeric), 2) end, t.estimated) from effort where effort.tid = t.tid) end) as remaining",
+ 'remaining' =>
+ // This is much more complex than I'd like it to be :-/
+ // This logic MUST be equivalent to that of MTrackIssue::getRemaining
+ // Logic is: if we have any non-zero effort entries, we sum them to
+ // get the remaining time, otherwise we use the estimated value.
+ // Except when the ticket is closed: show 0 then.
+ <<<SQL
+(
+ case when
+ t.status = 'closed' then
+ 0
+ else (
+ select round(cast(coalesce(sum(remaining), t.estimated) as numeric), 2)
+ from effort where effort.tid = t.tid and remaining != 0
+ )
+ end
+
+) as remaining
+SQL
+ ,
'state' => "(case when t.status = 'closed' then coalesce(t.resolution, 'closed') else t.status end) as state",
'milestone' => '(select mtrack_group_concat(name) from ticket_milestones
tmm left join milestones tmmm on (tmm.mid = tmmm.mid)

https://bitbucket.org/wez/mtrack/changeset/eae1e2c480ca/
changeset: eae1e2c480ca
user: wez
date: 2012-04-24 15:18:10
summary: since this is all differential, we're better (and correct!) to add the
initial estimate to the sum
affected #: 2 files

diff -r 1cb4b3f480f4e2a97133a7d5116625cdbd55e91e -r eae1e2c480caee26e86b83875f1238ab4c4780b7 inc/issue.php
--- a/inc/issue.php
+++ b/inc/issue.php
@@ -1722,7 +1722,7 @@
foreach (MTrackDB::q(<<<SQL
SELECT
count(remaining),
- round(cast(coalesce(sum(remaining), ?) as numeric), 2)
+ round(cast(? + coalesce(sum(remaining), 0) as numeric), 2)
FROM effort where tid = ? and remaining != 0
SQL
, $this->estimated, $this->tid


diff -r 1cb4b3f480f4e2a97133a7d5116625cdbd55e91e -r eae1e2c480caee26e86b83875f1238ab4c4780b7 inc/report.php
--- a/inc/report.php
+++ b/inc/report.php
@@ -581,7 +581,7 @@
t.status = 'closed' then
0
else (
- select round(cast(coalesce(sum(remaining), t.estimated) as numeric), 2)
+ select round(t.estimated + cast(coalesce(sum(remaining), 0) as numeric), 2)
from effort where effort.tid = t.tid and remaining != 0
)
end

https://bitbucket.org/wez/mtrack/changeset/dcef4a6dba21/
changeset: dcef4a6dba21
user: wez
date: 2012-04-24 15:25:44
summary: fix for postgres
affected #: 1 file

diff -r eae1e2c480caee26e86b83875f1238ab4c4780b7 -r dcef4a6dba21c4501869e2ec5750e26ac02d17d6 inc/report.php
--- a/inc/report.php
+++ b/inc/report.php
@@ -581,7 +581,7 @@
t.status = 'closed' then
0
else (
- select round(t.estimated + cast(coalesce(sum(remaining), 0) as numeric), 2)
+ select round(cast(t.estimated as numeric) + cast(coalesce(sum(remaining), 0) as numeric), 2)
from effort where effort.tid = t.tid and remaining != 0
)
end

https://bitbucket.org/wez/mtrack/changeset/2a76ab711b57/
changeset: 2a76ab711b57
user: wez
date: 2012-04-24 15:39:28
summary: don't allow negative time remaining to be shown.
need to add "greatest" function to sqlite for portability -- it is a
non-aggregating "max" function.
affected #: 3 files

diff -r dcef4a6dba21c4501869e2ec5750e26ac02d17d6 -r 2a76ab711b574771166b2806d19737401377469f inc/database.php
--- a/inc/database.php
+++ b/inc/database.php
@@ -427,6 +427,8 @@

$db->sqliteCreateFunction('mtrack_cleanup_attachments',
array('MTrackAttachment', 'attachment_row_deleted'));
+
+ $db->sqliteCreateFunction('greatest', 'max');
}

foreach (self::$extensions as $ext) {


diff -r dcef4a6dba21c4501869e2ec5750e26ac02d17d6 -r 2a76ab711b574771166b2806d19737401377469f inc/issue.php
--- a/inc/issue.php
+++ b/inc/issue.php
@@ -1729,7 +1729,7 @@
)->fetchAll() as $row) {
if ($row[0]) {
/* normalize floating point zero to precisely zero */
- return $row[1] == 0 ? 0 : $row[1];
+ return $row[1] == 0 ? 0 : max($row[1], 0);
}
}
return $this->estimated;


diff -r dcef4a6dba21c4501869e2ec5750e26ac02d17d6 -r 2a76ab711b574771166b2806d19737401377469f inc/report.php
--- a/inc/report.php
+++ b/inc/report.php
@@ -581,7 +581,14 @@
t.status = 'closed' then
0
else (
- select round(cast(t.estimated as numeric) + cast(coalesce(sum(remaining), 0) as numeric), 2)
+ select
+ greatest(
+ round(
+ cast(t.estimated as numeric) +
+ cast(coalesce(sum(remaining), 0) as numeric
+ ), 2),
+ 0
+ )
from effort where effort.tid = t.tid and remaining != 0
)
end

Repository URL: https://bitbucket.org/wez/mtrack/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Reply all
Reply to author
Forward
0 new messages