[yocto] [rrs][PATCH 2/3] views.py: Changed the behavior of percentage done

mariano.lopez at linux.intel.com mariano.lopez at linux.intel.com
Thu Jul 9 08:39:13 PDT 2015


From: Mariano Lopez <mariano.lopez at linux.intel.com>

This changes the percetage done from recipes up to date
in the period to percentage of not updated recipes that
were updated in the period.

Signed-off-by: Mariano Lopez <mariano.lopez at linux.intel.com>
---
 rrs/views.py | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/rrs/views.py b/rrs/views.py
index fc43d7d..8716753 100644
--- a/rrs/views.py
+++ b/rrs/views.py
@@ -40,10 +40,26 @@ def _get_milestone_statistics(milestone, maintainer_name=None):
         milestone.start_date,
         milestone.end_date
     )
+    recipe_upstream_history_first = \
+        RecipeUpstreamHistory.get_first_by_date_range(
+            milestone.start_date,
+            milestone.end_date,
+    )
 
     if maintainer_name is None:
-        milestone_statistics['all'] = \
-            RecipeUpstream.get_all_recipes(recipe_upstream_history).count()
+        if recipe_upstream_history_first:
+            recipes_not_upgraded = \
+                Raw.get_reup_by_date(recipe_upstream_history_first.id)
+            recipes_upgraded = \
+                Raw.get_reupg_by_dates_and_recipes(
+                    milestone.start_date, milestone.end_date, recipes_not_upgraded)
+            milestone_statistics['all'] = \
+                float(len(recipes_upgraded))/float(len(recipes_not_upgraded))
+        else:
+            milestone_statistics['all'] = 0
+
+        milestone_statistics['percentage'] = "%.0f" % \
+            (float(milestone_statistics['all']) * 100.0)
         milestone_statistics['up_to_date'] = \
             RecipeUpstream.get_recipes_up_to_date(recipe_upstream_history).count()
         milestone_statistics['not_updated'] = \
@@ -79,13 +95,12 @@ def _get_milestone_statistics(milestone, maintainer_name=None):
                     milestone_statistics['cant_be_updated'] += 1
             else:
                 milestone_statistics['unknown'] += 1
-
-    if milestone_statistics['all'] == 0:
-        milestone_statistics['percentage'] = 0
-    else:
-        milestone_statistics['percentage'] = "%.0f" % \
-            ((float(milestone_statistics['up_to_date']) /
-                float(milestone_statistics['all'])) * 100)
+        if milestone_statistics['all'] == 0:
+            milestone_statistics['percentage'] = '0'
+        else:
+            milestone_statistics['percentage'] = "%.0f" % \
+                ((float(milestone_statistics['up_to_date']) /
+                    float(milestone_statistics['all'])) * 100)
 
     return milestone_statistics
 
-- 
1.9.1




More information about the yocto mailing list