From b2e04c0a9e118287c3c781036a82cb35b739cf35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= Date: Tue, 14 Jul 2015 18:22:14 -0500 Subject: [PATCH] rrs: Fix last updated. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't conditional last updated to upstream status. Signed-off-by: Aníbal Limón --- rrs/models.py | 12 +++--------- rrs/views.py | 25 ++++++++++++------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/rrs/models.py b/rrs/models.py index 144ca16..abc9d5b 100644 --- a/rrs/models.py +++ b/rrs/models.py @@ -449,15 +449,9 @@ class Raw(): def get_reup_by_last_updated(date): """ Get last time the Recipes were upgraded """ 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; + cur.execute("""SELECT recipe_id, MAX(commit_date) AS date + FROM rrs_recipeupgrade + GROUP BY recipe_id; """, [date]) return Raw.dictfetchall(cur) diff --git a/rrs/views.py b/rrs/views.py index 7fce084..ee68254 100644 --- a/rrs/views.py +++ b/rrs/views.py @@ -145,22 +145,23 @@ def _get_recipe_list(milestone): recipes[i]['version'] = re['pv'] recipes_ids.append(re['id']) - if recipes and recipe_upstream_history: - recipe_upstream_all = Raw.get_reup_by_recipes_and_date( - recipes_ids, recipe_upstream_history.id) + if recipes: 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 + if recipe_upstream_history: + recipe_upstream_all = Raw.get_reup_by_recipes_and_date( + recipes_ids, recipe_upstream_history.id) + for reup in recipe_upstream_all: + recipe_upstream_dict_all[reup['recipe_id']] = reup + + if recipe_maintainer_history: + maintainers_all = Raw.get_ma_by_recipes_and_date( + recipes_ids, recipe_maintainer_history[0]) + for ma in maintainers_all: + maintainers_dict_all[ma['recipe_id']] = ma['name'] for recipe in recipes: upstream_version = '' @@ -201,8 +202,6 @@ def _get_recipe_list(milestone): if recipe_last_updated: recipe_date = recipe_last_updated['date'] outdated = recipe_date.date().isoformat() - else: - outdated = 'Unknown' else: outdated = 'Up-to-date'