All of lore.kernel.org
 help / color / mirror / Atom feed
* [rrs][PATCH 0/3] Change behavior of the percentage done
@ 2015-07-09 15:39 mariano.lopez
  2015-07-09 15:39 ` [rrs][PATCH 1/3] models.py: Added Raw SQL for percentage updated mariano.lopez
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mariano.lopez @ 2015-07-09 15:39 UTC (permalink / raw)
  To: yocto

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

This patches changes the behavior of the percentage done to
display the percentage of out to date recipes that were
updated in the period.

models.py: Added SQL queries
views.py: Changed the behavior
base_toplevel.html: Changed format of the webpage

Mariano Lopez (3):
  models.py: Added Raw SQL for percentage updated
  views.py: Changed the behavior of percentage done
  base_toplevel.html: Changed format of percentage done

 rrs/models.py                    | 44 ++++++++++++++++++++++++++++++++++++++++
 rrs/views.py                     | 33 ++++++++++++++++++++++--------
 templates/rrs/base_toplevel.html |  2 +-
 3 files changed, 69 insertions(+), 10 deletions(-)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [rrs][PATCH 1/3] models.py: Added Raw SQL for percentage updated
  2015-07-09 15:39 [rrs][PATCH 0/3] Change behavior of the percentage done mariano.lopez
@ 2015-07-09 15:39 ` mariano.lopez
  2015-07-09 15:39 ` [rrs][PATCH 2/3] views.py: Changed the behavior of percentage done mariano.lopez
  2015-07-09 15:39 ` [rrs][PATCH 3/3] base_toplevel.html: Changed format " mariano.lopez
  2 siblings, 0 replies; 4+ messages in thread
From: mariano.lopez @ 2015-07-09 15:39 UTC (permalink / raw)
  To: yocto

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

This adds SQL queries that will be used for the
percentage of recipes updated in a period.

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 rrs/models.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/rrs/models.py b/rrs/models.py
index 4608f9f..1ce63df 100644
--- a/rrs/models.py
+++ b/rrs/models.py
@@ -235,6 +235,16 @@ class RecipeUpstreamHistory(models.Model):
             return None
 
     @staticmethod
+    def get_first_by_date_range(start, end):
+        history = RecipeUpstreamHistory.objects.filter(start_date__gte = start,
+                start_date__lte = end).order_by('start_date')
+
+        if history:
+            return history[0]
+        else:
+            return None
+
+    @staticmethod
     def get_last():
         history = RecipeUpstreamHistory.objects.filter().order_by('-start_date')
 
@@ -475,6 +485,40 @@ class Raw():
         return Raw.dictfetchall(cur)
 
     @staticmethod
+    def get_reup_by_date(date_id):
+        cur = connection.cursor()
+        cur.execute("""SELECT DISTINCT recipe_id
+                    FROM rrs_RecipeUpstream
+                    WHERE status = 'N'
+                    AND history_id = %s
+                    """, [date_id])
+        return [i[0] for i in cur.fetchall()]
+
+    @staticmethod
+    def get_reupg_by_dates(start_date, end_date):
+        cur = connection.cursor()
+        cur.execute("""SELECT id, recipe_id, maintainer_id, author_date, commit_date
+                    FROM rrs_recipeupgrade
+                    WHERE commit_date >= %s
+                    AND commit_date <= %s
+                    ORDER BY commit_date DESC;
+                    """, [start_date, end_date])
+        return Raw.dictfetchall(cur)
+
+    @staticmethod
+    def get_reupg_by_dates_and_recipes(start_date, end_date, recipes_id):
+        recipes = str(recipes_id).strip('[]')
+
+        cur = connection.cursor()
+        qry = """SELECT DISTINCT recipe_id
+                FROM rrs_RecipeUpgrade"""
+        qry += "\nWHERE commit_date >= '%s'" % str(start_date)
+        qry += "\nAND commit_date <= '%s'" % str(end_date)
+        qry += "\nAND recipe_id IN (%s);" % recipes
+        cur.execute(qry)
+        return Raw.dictfetchall(cur)
+
+    @staticmethod
     def dictfetchall(cursor):
         "Returns all rows from a cursor as a dict"
         desc = cursor.description
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [rrs][PATCH 2/3] views.py: Changed the behavior of percentage done
  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
  2015-07-09 15:39 ` [rrs][PATCH 3/3] base_toplevel.html: Changed format " mariano.lopez
  2 siblings, 0 replies; 4+ messages in thread
From: mariano.lopez @ 2015-07-09 15:39 UTC (permalink / raw)
  To: yocto

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [rrs][PATCH 3/3] base_toplevel.html: Changed format of percentage done
  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 ` [rrs][PATCH 2/3] views.py: Changed the behavior of percentage done mariano.lopez
@ 2015-07-09 15:39 ` mariano.lopez
  2 siblings, 0 replies; 4+ messages in thread
From: mariano.lopez @ 2015-07-09 15:39 UTC (permalink / raw)
  To: yocto

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

Changed the text of percentage done to updated. Also
added a tooltip that shows how this percentage is calculated.

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 templates/rrs/base_toplevel.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/templates/rrs/base_toplevel.html b/templates/rrs/base_toplevel.html
index 9804c03..fd0c96c 100644
--- a/templates/rrs/base_toplevel.html
+++ b/templates/rrs/base_toplevel.html
@@ -66,7 +66,7 @@
                     </span>
                     <ul class="nav">
                         <li class="divider-vertical"></li>
-                        <li class="lead" id="percentage"><strong>{{ recipes_percentage }}%</strong> done</li>
+                        <li class="lead" id="percentage" data-toggle="tooltip" title="Upgrades done in the period divided by recipes not updated at the beginning of the period"><strong>{{ recipes_percentage }}%</strong> Updated</li>
                         <li class="divider-vertical"></li>
                         <li class="lead" id="up-to-date-recipes">Up-to-date: <span class="text-success">{{ recipes_up_to_date }}</strong></li>
                         <li class="divider-vertical"></li>
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-09 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [rrs][PATCH 2/3] views.py: Changed the behavior of percentage done mariano.lopez
2015-07-09 15:39 ` [rrs][PATCH 3/3] base_toplevel.html: Changed format " mariano.lopez

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.