All of lore.kernel.org
 help / color / mirror / Atom feed
From: mariano.lopez@linux.intel.com
To: yocto@yoctoproject.org
Subject: [rrs][PATCH 2/3] views.py: Changed the behavior of percentage done
Date: Thu,  9 Jul 2015 10:39:13 -0500	[thread overview]
Message-ID: <1436456354-6416-3-git-send-email-mariano.lopez@linux.intel.com> (raw)
In-Reply-To: <1436456354-6416-1-git-send-email-mariano.lopez@linux.intel.com>

From: Mariano Lopez <mariano.lopez@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@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



  parent reply	other threads:[~2015-07-09 15:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09 15:39 [rrs][PATCH 0/3] Change behavior of the percentage done mariano.lopez
2015-07-09 15:39 ` [rrs][PATCH 1/3] models.py: Added Raw SQL for percentage updated mariano.lopez
2015-07-09 15:39 ` mariano.lopez [this message]
2015-07-09 15:39 ` [rrs][PATCH 3/3] base_toplevel.html: Changed format of percentage done mariano.lopez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436456354-6416-3-git-send-email-mariano.lopez@linux.intel.com \
    --to=mariano.lopez@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.