views.py: Add how long a recipe hasn't been updated
PATCH 1/1 views.py: Add how long a recipe hasn't been updated
From: Mariano Lopez <[email protected]>
This add a tooltip in the upstream status field that show how long the recipe hasn't been updated.
--- rrs/models.py | 15 +++++++++++++++ rrs/views.py | 23 ++++++++++++++++++++++- templates/rrs/recipes.html | 8 ++++---- 3 files changed, 41 insertions(+), 5 deletions(-)
rrs/models.py +15 -0
@@ -448,6 +448,21 @@ class Raw(): return Raw.dictfetchall(cur) @staticmethod + def get_reup_by_last_updated(date): + cur = connection.cursor() + cur.execute("""SELECT te.recipe_id, te.status, te.date, te.rownum FROM( + SELECT recipe_id, status, date, ROW_NUMBER() OVER( + PARTITION BY recipe_id + ORDER BY date DESC + ) AS rownum + FROM rrs_RecipeUpstream + WHERE status = 'Y' + AND date <= %s) AS te + WHERE te.rownum = 1; + """, [date]) + return Raw.dictfetchall(cur) + + @staticmethod def dictfetchall(cursor): "Returns all rows from a cursor as a dict" desc = cursor.description
rrs/views.py +22 -1
@@ -3,7 +3,7 @@ import urllib import csv from django.http import HttpResponse -from datetime import date +from datetime import date, datetime from django.http import Http404 from django.shortcuts import get_object_or_404 from django.views.generic import ListView, DetailView
@@ -96,6 +96,7 @@ class RecipeList(): summary = None upstream_status = None upstream_version = None + outdated = None maintainer_name = None no_update_reason = None
@@ -116,6 +117,7 @@ def _get_recipe_list(milestone): recipe_list = [] recipes_ids = [] recipe_upstream_dict_all = {} + recipe_last_updated_dict_all = {} maintainers_dict_all = {} current_date = date.today()
@@ -127,12 +129,17 @@ def _get_recipe_list(milestone): if recipe_upstream_history: recipe_upstream_all = Raw.get_reup_by_recipes_and_date( recipes_ids, recipe_upstream_history.id) + recipe_last_updated = Raw.get_reup_by_last_updated( + milestone.end_date) maintainers_all = Raw.get_ma_by_recipes_and_date( recipes_ids, recipe_maintainer_history[0]) for reup in recipe_upstream_all: recipe_upstream_dict_all[reup['recipe_id']] = reup + for rela in recipe_last_updated: + recipe_last_updated_dict_all[rela['recipe_id']] = rela for ma in maintainers_all: maintainers_dict_all[ma['recipe_id']] = ma['name'] + else: recipe_upstream_all = None
@@ -140,6 +147,7 @@ def _get_recipe_list(milestone): upstream_version = '' upstream_status = '' no_update_reason = '' + outdated = '' if recipe_upstream_history: recipe_upstream = recipe_upstream_dict_all.get(recipe['id'])
@@ -167,11 +175,24 @@ def _get_recipe_list(milestone): upstream_version = recipe_upstream['version'] no_update_reason = recipe_upstream['no_update_reason'] + #Get how long the recipe hasn't been updated + if recipe_upstream['status'] != 'Y': + recipe_last_updated = \ + recipe_last_updated_dict_all.get(recipe['id']) + if recipe_last_updated: + recipe_date = recipe_last_updated['date'] + outdated = (current_date - recipe_date.date()).days + else: + outdated = 'Unknown' + else: + outdated = 'Up-to-date' + maintainer_name = maintainers_dict_all.get(recipe['id'], '') recipe_list_item = RecipeList(recipe['id'], recipe['pn'], recipe['summary']) recipe_list_item.version = recipe['version'] recipe_list_item.upstream_status = upstream_status recipe_list_item.upstream_version = upstream_version + recipe_list_item.outdated = outdated recipe_list_item.maintainer_name = maintainer_name recipe_list_item.no_update_reason = no_update_reason recipe_list.append(recipe_list_item)
templates/rrs/recipes.html +4 -4
@@ -88,13 +88,13 @@ <td class="version_column">{{ r.version }}</td> <td class="upstream_version_column">{{ r.upstream_version }}</td> {% if r.upstream_status == "Up-to-date" %} - <td class="text-success"> + <td class="text-success" data-toggle="tooltip" title="{{r.outdated}}"> {% elif r.upstream_status == "Not updated" %} - <td class="text-error"> + <td class="text-error" data-toggle="tooltip" title="{{r.outdated}}"> {% elif r.upstream_status == "Can't be updated" %} - <td class="muted"> + <td class="muted" data-toggle="tooltip" title="{{r.outdated}}"> {% else %} - <td class="text-warning"> + <td class="text-warning" data-toggle="tooltip" title="{{r.outdated}}"> {% endif %} {{ r.upstream_status }} </td>
Signature · 1 line
1.9.1
Quoted 4 lines · On 26/06/2015 20:35, "[email protected]"…
From: Mariano Lopez <[email protected]>
This add a tooltip in the upstream status field that show how long the recipe hasn't been updated.
A tooltip is probably not the best way of showing this. If this information is of interest in the context of the recipes table, I would suggest adding a "Last update" column to the table, between the 'Upstream status' and the 'Maintainer' columns. The 'Last update' column should be sortable if possible.
To improve readability and facilitate comparison between values in the table, I would change the date format, since the one we are currently using (e.g. Dec. 9, 2013, 6:01 p.m.) is too verbose. Something like MM/DD/YYYY (or DD/MM/YYYY) would work better. Also, I would remove the time, since it is probably not that relevant in this context (does it really matter if the patch was merged at 6:01 pm or at 3:25 pm?).
The date format should be changed across the tool (both in the recipes table and the recipe details page).
Cheers
Belén
Quoted 148 lines
Signed-off-by Mariano Lopez <[email protected]>---
rrs/models.py | 15 +++++++++++++++ rrs/views.py | 23 ++++++++++++++++++++++- templates/rrs/recipes.html | 8 ++++---- 3 files changed, 41 insertions(+), 5 deletions(-)rrs/models.py +3
-0@@ -448,6 +448,21 @@ class Raw(): return Raw.dictfetchall(cur) @staticmethod + def get_reup_by_last_updated(date): + cur = connection.cursor() + cur.execute("""SELECT te.recipe_id, te.status, te.date,te.rownum FROM(
rrs/models.py +12
-0+ SELECT recipe_id, status, date, ROW_NUMBER() OVER( + PARTITION BY recipe_id + ORDER BY date DESC + ) AS rownum + FROM rrs_RecipeUpstream + WHERE status = 'Y' + AND date <= %s) AS te + WHERE te.rownum = 1; + """, [date]) + return Raw.dictfetchall(cur) + + @staticmethod def dictfetchall(cursor): "Returns all rows from a cursor as a dict" desc = cursor.descriptionrrs/views.py +0
-0@@ -3,7 +3,7 @@ import urllibimport csv
from django.http import HttpResponserrs/views.py +1
-1-from datetime import date +from datetime import date, datetimefrom django.http import Http404
from django.shortcuts importget_object_or_404from django.views.generic import ListView, DetailViewrrs/views.py +21
-0@@ -96,6 +96,7 @@ class RecipeList(): summary = None upstream_status = None upstream_version = None + outdated = None maintainer_name = None no_update_reason = None@@ -116,6 +117,7 @@ def _get_recipe_list(milestone): recipe_list = [] recipes_ids = [] recipe_upstream_dict_all = {} + recipe_last_updated_dict_all = {} maintainers_dict_all = {} current_date = date.today()@@ -127,12 +129,17 @@ def _get_recipe_list(milestone): if recipe_upstream_history: recipe_upstream_all = Raw.get_reup_by_recipes_and_date( recipes_ids, recipe_upstream_history.id) + recipe_last_updated = Raw.get_reup_by_last_updated( + milestone.end_date) maintainers_all = Raw.get_ma_by_recipes_and_date( recipes_ids, recipe_maintainer_history[0]) for reup in recipe_upstream_all: recipe_upstream_dict_all[reup['recipe_id']] = reup + for rela in recipe_last_updated: + recipe_last_updated_dict_all[rela['recipe_id']] = rela for ma in maintainers_all: maintainers_dict_all[ma['recipe_id']] = ma['name'] + else: recipe_upstream_all = None@@ -140,6 +147,7 @@ def _get_recipe_list(milestone): upstream_version = '' upstream_status = '' no_update_reason = '' + outdated = '' if recipe_upstream_history: recipe_upstream = recipe_upstream_dict_all.get(recipe['id'])@@ -167,11 +175,24 @@ def _get_recipe_list(milestone): upstream_version = recipe_upstream['version'] no_update_reason = recipe_upstream['no_update_reason'] + #Get how long the recipe hasn't been updated + if recipe_upstream['status'] != 'Y': + recipe_last_updated = \ + recipe_last_updated_dict_all.get(recipe['id']) + if recipe_last_updated: + recipe_date = recipe_last_updated['date'] + outdated = (current_date - recipe_date.date()).days + else: + outdated = 'Unknown' + else: + outdated = 'Up-to-date' + maintainer_name = maintainers_dict_all.get(recipe['id'], '') recipe_list_item = RecipeList(recipe['id'], recipe['pn'], recipe['summary']) recipe_list_item.version = recipe['version'] recipe_list_item.upstream_status = upstream_status recipe_list_item.upstream_version = upstream_version + recipe_list_item.outdated = outdated recipe_list_item.maintainer_name = maintainer_name recipe_list_item.no_update_reason = no_update_reason
recipe_list.append(recipe_list_item)templates/rrs/recipes.html +1
-1@@ -88,13 +88,13 @@ <td class="version_column">{{ r.version }}</td> <td class="upstream_version_column">{{ r.upstream_version }}</td> {% if r.upstream_status == "Up-to-date" %} - <td class="text-success"> + <td class="text-success" data-toggle="tooltip"title="{{r.outdated}}">
{% elif r.upstream_status == "Not updated" %}templates/rrs/recipes.html +3
-3- <td class="text-error"> + <td class="text-error" data-toggle="tooltip" title="{{r.outdated}}"> {% elif r.upstream_status == "Can't be updated" %} - <td class="muted"> + <td class="muted" data-toggle="tooltip" title="{{r.outdated}}"> {% else %} - <td class="text-warning"> + <td class="text-warning" data-toggle="tooltip"title="{{r.outdated}}">
{% endif %} {{ r.upstream_status }} </td>Signature · 7 lines
1.9.1 -- _______________________________________________ yocto mailing list [email protected] https://lists.yoctoproject.org/listinfo/yocto