Skip to content

Commit

Permalink
modified a little sql to make it work with postgres iRessources#9 (co…
Browse files Browse the repository at this point in the history
…mment) (needs to be refined further to be platform independent); modified burndown.js according to iRessources#36 (comment) also fixed incorrect case of issueId to issueid
  • Loading branch information
Brian Muckian committed Nov 11, 2012
1 parent 2cc0118 commit 0dac149
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/controllers/adburndown_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def show
@changes = []
# restcondchanges = ActiveRecord::Base::sanitize_sql(restcondtasks)
restcondchanges = ActiveRecord::Base.send(:sanitize_sql, restcondtasks, '')
ActiveRecord::Base.connection.select_all("select * from (select old_value as value, journalized_id as issueId, prop_key, DATE(journals.created_on) created_on from `journals` inner join journal_details on (journals.id = journal_id) inner join issues on (issues.id = journalized_id) where journalized_type = 'Issue' and property = 'attr' and (prop_key = 'estimated_hours' or prop_key = 'done_ratio') and #{restcondchanges} order by journals.id desc) a group by `issueId`, created_on, prop_key order by created_on desc").each{|row| @changes << row}
ActiveRecord::Base.connection.select_all("select max(COALESCE(old_value::float,0)) as value, journalized_id as issueId, prop_key, DATE(journals.created_on) AS created_on from journals inner join journal_details on (journals.id = journal_id) inner join issues on (issues.id = journalized_id) where journalized_type = 'Issue' and property = 'attr' and (prop_key = 'estimated_hours' or prop_key = 'done_ratio') and #{restcondchanges} group by 2, 3, 4 order by created_on desc").each{|row| @changes << row}
=begin
select * from
(
Expand All @@ -77,4 +77,4 @@ def find_project
# @project variable must be set before calling the authorize filter
@project = Project.find(params[:project_id])
end
end
end
8 changes: 5 additions & 3 deletions app/views/adburndown/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script type="text/javascript">
Burndown.setOptions(
{
title: {text: 'Burn-down chart for <%=h @sprintName || 'whole project' %>'},
title: {text: 'burn-down chart'},
yAxis: {title: {text: '<%= l(:label_burndown_axis_y_name) %>'}},
tooltip:
{
Expand Down Expand Up @@ -35,6 +35,10 @@
});
</script>


<div id="burndown">
</div>

<h2><%= l(:label_menu_burndown) %></h2>

<div class="fl">
Expand All @@ -58,5 +62,3 @@
</div>
</div>

<div id="burndown">
</div>
15 changes: 8 additions & 7 deletions assets/javascripts/burndown.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ var Burndown = function ($)
if (typeof mysql != 'string')
return null;
// 2011/11/03 00:00:00 +0800
var t = mysql.split(/[\/ \-:]/);
// var t = mysql.split(/[\/ \-:]/);
var t = mysql.split('-');
// [Y, M, D]
return Date.UTC(t[0], t[1] - 1, t[2]);
return Date.UTC(t[0], t[1] - 1, t[2].substr(0,2));
};

obj.setSettings = function (s)
Expand Down Expand Up @@ -45,7 +46,7 @@ var Burndown = function ($)
{
if (!tasks.hasOwnProperty(id))
continue;
tasks[id].created_on = Date.fromMysql(tasks[id].created_on);
tasks[id].sprints_tasks.created_on = Date.fromMysql(tasks[id].sprints_tasks.created_on);
}
// loop through changes
for (i = 0, len = changes.length; i < len; )
Expand All @@ -59,7 +60,7 @@ var Burndown = function ($)
{
if (!tasks.hasOwnProperty(id))
continue;
var task = tasks[id];
var task = tasks[id].sprints_tasks;
// delete tasks, that was created after current date
if (task.created_on > dateTime)
delete tasks[id];
Expand All @@ -76,9 +77,9 @@ var Burndown = function ($)
while (dateTime == changeDate)
{
if (changes[i].prop_key == 'done_ratio')
tasks[changes[i].issueId].done_ratio = changes[i].value;
tasks[changes[i].issueid].sprints_tasks.done_ratio = changes[i].value;
else
tasks[changes[i].issueId].estimated_hours = changes[i].value;
tasks[changes[i].issueid].sprints_tasks.estimated_hours = changes[i].value;
// next change
i++;
if (i >= len)
Expand Down Expand Up @@ -209,4 +210,4 @@ var Burndown = function ($)
});

return obj;
}(jQuery);
}(jQuery);

0 comments on commit 0dac149

Please sign in to comment.