rrs/views.py: Added percentages for navbar

This adds the percentage for all the recipes types
(up-to-date, not updated, unknown, can't be updated)
so it can be displayed in the navbar.

This also adds the number of the recipes not updated
at the begining of the period and number of recipes
updated in the period.

The changes in the frontend are still missing, this
just adds the functionality.

[YOCTO #8020]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
This commit is contained in:
Mariano Lopez 2015-08-17 10:30:12 -05:00 committed by Paul Eggleton
parent 66c0b28982
commit 6aa369757c

View File

@ -47,22 +47,8 @@ def _get_milestone_statistics(milestone, maintainer_name=None):
) )
if maintainer_name is None: if maintainer_name is None:
if recipe_upstream_history_first: milestone_statistics['all'] = \
recipes_not_upgraded = \ RecipeUpstream.get_all_recipes(recipe_upstream_history).count()
Raw.get_reup_by_date(recipe_upstream_history_first.id)
if recipes_not_upgraded:
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
else:
milestone_statistics['all'] = 0
milestone_statistics['percentage'] = "%.0f" % \
(float(milestone_statistics['all']) * 100.0)
milestone_statistics['up_to_date'] = \ milestone_statistics['up_to_date'] = \
RecipeUpstream.get_recipes_up_to_date(recipe_upstream_history).count() RecipeUpstream.get_recipes_up_to_date(recipe_upstream_history).count()
milestone_statistics['not_updated'] = \ milestone_statistics['not_updated'] = \
@ -71,6 +57,39 @@ def _get_milestone_statistics(milestone, maintainer_name=None):
RecipeUpstream.get_recipes_cant_be_updated(recipe_upstream_history).count() RecipeUpstream.get_recipes_cant_be_updated(recipe_upstream_history).count()
milestone_statistics['unknown'] = \ milestone_statistics['unknown'] = \
RecipeUpstream.get_recipes_unknown(recipe_upstream_history).count() RecipeUpstream.get_recipes_unknown(recipe_upstream_history).count()
milestone_statistics['percentage'] = 0
milestone_statistics['all_upgraded'] = 0
milestone_statistics['all_not_upgraded'] = 0
milestone_statistics['percentage_up_to_date'] = 0
milestone_statistics['percentage_not_updated'] = 0
milestone_statistics['percentage_cant_be_updated'] = 0
milestone_statistics['percentage_unknown'] = 0
if recipe_upstream_history_first:
recipes_not_upgraded = \
Raw.get_reup_by_date(recipe_upstream_history_first.id)
if recipes_not_upgraded:
recipes_upgraded = \
Raw.get_reupg_by_dates_and_recipes(
milestone.start_date, milestone.end_date, recipes_not_upgraded)
milestone_statistics['percentage'] = "%.0f" % \
((float(len(recipes_upgraded)) * 100.0)
/float(len(recipes_not_upgraded)))
milestone_statistics['all_upgraded'] = len(recipes_upgraded)
milestone_statistics['all_not_upgraded'] = len(recipes_not_upgraded)
milestone_statistics['percentage_up_to_date'] = "%.0f" % \
(float(milestone_statistics['up_to_date']) * 100.0 \
/float(milestone_statistics['all']))
milestone_statistics['percentage_not_updated'] = "%.0f" % \
(float(milestone_statistics['not_updated']) * 100.0 \
/float(milestone_statistics['all']))
milestone_statistics['percentage_cant_be_updated'] = "%.0f" % \
(float(milestone_statistics['cant_be_updated']) * 100.0 \
/float(milestone_statistics['all']))
milestone_statistics['percentage_unknown'] = "%.0f" % \
(float(milestone_statistics['unknown']) * 100.0
/float(milestone_statistics['all']))
else: else:
recipe_maintainer_history = Raw.get_remahi_by_end_date( recipe_maintainer_history = Raw.get_remahi_by_end_date(
milestone.end_date) milestone.end_date)
@ -259,10 +278,20 @@ class RecipeListView(ListView):
context['all_milestones'] = Milestone.get_by_release_name(self.release_name) context['all_milestones'] = Milestone.get_by_release_name(self.release_name)
context['recipes_percentage'] = self.milestone_statistics['percentage'] context['recipes_percentage'] = self.milestone_statistics['percentage']
context['recipes_all_upgraded'] = self.milestone_statistics['all_upgraded']
context['recipes_all_not_upgraded'] = self.milestone_statistics['all_not_upgraded']
context['recipes_up_to_date'] = self.milestone_statistics['up_to_date'] context['recipes_up_to_date'] = self.milestone_statistics['up_to_date']
context['recipes_not_updated'] = self.milestone_statistics['not_updated'] context['recipes_not_updated'] = self.milestone_statistics['not_updated']
context['recipes_cant_be_updated'] = self.milestone_statistics['cant_be_updated'] context['recipes_cant_be_updated'] = self.milestone_statistics['cant_be_updated']
context['recipes_unknown'] = self.milestone_statistics['unknown'] context['recipes_unknown'] = self.milestone_statistics['unknown']
context['recipes_percentage_up_to_date'] = \
self.milestone_statistics['percentage_up_to_date']
context['recipes_percentage_not_updated'] = \
self.milestone_statistics['percentage_not_updated']
context['recipes_percentage_cant_be_updated'] = \
self.milestone_statistics['percentage_cant_be_updated']
context['recipes_percentage_unknown'] = \
self.milestone_statistics['percentage_unknown']
context['recipe_list_count'] = self.recipe_list_count context['recipe_list_count'] = self.recipe_list_count
@ -519,10 +548,20 @@ class MaintainerListView(ListView):
context['all_milestones'] = Milestone.get_by_release_name(self.release_name) context['all_milestones'] = Milestone.get_by_release_name(self.release_name)
context['recipes_percentage'] = self.milestone_statistics['percentage'] context['recipes_percentage'] = self.milestone_statistics['percentage']
context['recipes_all_upgraded'] = self.milestone_statistics['all_upgraded']
context['recipes_all_not_upgraded'] = self.milestone_statistics['all_not_upgraded']
context['recipes_up_to_date'] = self.milestone_statistics['up_to_date'] context['recipes_up_to_date'] = self.milestone_statistics['up_to_date']
context['recipes_not_updated'] = self.milestone_statistics['not_updated'] context['recipes_not_updated'] = self.milestone_statistics['not_updated']
context['recipes_cant_be_updated'] = self.milestone_statistics['cant_be_updated'] context['recipes_cant_be_updated'] = self.milestone_statistics['cant_be_updated']
context['recipes_unknown'] = self.milestone_statistics['unknown'] context['recipes_unknown'] = self.milestone_statistics['unknown']
context['recipes_percentage_up_to_date'] = \
self.milestone_statistics['percentage_up_to_date']
context['recipes_percentage_not_updated'] = \
self.milestone_statistics['percentage_not_updated']
context['recipes_percentage_cant_be_updated'] = \
self.milestone_statistics['percentage_cant_be_updated']
context['recipes_percentage_unknown'] = \
self.milestone_statistics['percentage_unknown']
context['maintainer_count'] = self.maintainer_count context['maintainer_count'] = self.maintainer_count
context['intervals'] = self.intervals context['intervals'] = self.intervals