fix stats NaN

stable
Juanfran 2014-07-30 14:45:15 +02:00
parent 1a8fa8091e
commit 256de1a791
2 changed files with 12 additions and 2 deletions

View File

@ -73,7 +73,12 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
loadProjectStats: -> loadProjectStats: ->
return @rs.projects.stats(@scope.projectId).then (stats) => return @rs.projects.stats(@scope.projectId).then (stats) =>
@scope.stats = stats @scope.stats = stats
if stats.total_points
completedPercentage = Math.round(100 * stats.closed_points / stats.total_points) completedPercentage = Math.round(100 * stats.closed_points / stats.total_points)
else
completedPercentage = 0
@scope.stats.completedPercentage = "#{completedPercentage}%" @scope.stats.completedPercentage = "#{completedPercentage}%"
return stats return stats

View File

@ -98,7 +98,12 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
loadProjectStats: -> loadProjectStats: ->
return @rs.projects.stats(@scope.projectId).then (stats) => return @rs.projects.stats(@scope.projectId).then (stats) =>
@scope.stats = stats @scope.stats = stats
if stats.total_points
completedPercentage = Math.round(100 * stats.closed_points / stats.total_points) completedPercentage = Math.round(100 * stats.closed_points / stats.total_points)
else
completedPercentage = 0
@scope.stats.completedPercentage = "#{completedPercentage}%" @scope.stats.completedPercentage = "#{completedPercentage}%"
return stats return stats