mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
rrs: link maintenance/upstream history to layerbranch
RecipeUpstreamHistory was not linked to the layer it was produced from, which meant that it wasn't easy to query for a different maintenance plan (i.e. a different layer) and thus the maintenance plan selection on the recipe list didn't really work. Add a link field, populate it in a migration and then make it required. We had added a link earlier from RecipeMaintainerHistory to LayerBranch but it was optional; for the same reasons we now populate it and make it required. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
da3bfff3a1
commit
7606664eeb
|
@ -87,7 +87,7 @@ class MaintainerAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
class RecipeMaintainerHistoryAdmin(admin.ModelAdmin):
|
class RecipeMaintainerHistoryAdmin(admin.ModelAdmin):
|
||||||
search_fields = ['title', 'author__name', 'sha1']
|
search_fields = ['title', 'author__name', 'sha1']
|
||||||
list_filter = ['author__name', ('date', DateFieldListFilter)]
|
list_filter = ['layerbranch__layer', 'author__name', ('date', DateFieldListFilter)]
|
||||||
model = RecipeMaintainerHistory
|
model = RecipeMaintainerHistory
|
||||||
|
|
||||||
class RecipeMaintainerAdmin(admin.ModelAdmin):
|
class RecipeMaintainerAdmin(admin.ModelAdmin):
|
||||||
|
@ -108,6 +108,7 @@ class RecipeUpgradeAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
class RecipeUpstreamHistoryAdmin(admin.ModelAdmin):
|
class RecipeUpstreamHistoryAdmin(admin.ModelAdmin):
|
||||||
list_filter = [
|
list_filter = [
|
||||||
|
'layerbranch__layer',
|
||||||
('start_date', DateFieldListFilter),
|
('start_date', DateFieldListFilter),
|
||||||
('end_date', DateFieldListFilter)
|
('end_date', DateFieldListFilter)
|
||||||
]
|
]
|
||||||
|
|
19
rrs/migrations/0012_reup_layerbranch_field.py
Normal file
19
rrs/migrations/0012_reup_layerbranch_field.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('rrs', '0011_release_name_unique'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='recipeupstreamhistory',
|
||||||
|
name='layerbranch',
|
||||||
|
field=models.ForeignKey(null=True, to='layerindex.LayerBranch'),
|
||||||
|
),
|
||||||
|
]
|
29
rrs/migrations/0013_reup_layerbranch_populate.py
Normal file
29
rrs/migrations/0013_reup_layerbranch_populate.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import settings
|
||||||
|
|
||||||
|
|
||||||
|
def populate_layerbranch(apps, schema_editor):
|
||||||
|
RecipeUpstreamHistory = apps.get_model('rrs', 'RecipeUpstreamHistory')
|
||||||
|
LayerBranch = apps.get_model('layerindex', 'LayerBranch')
|
||||||
|
if not settings.CORE_LAYER_NAME:
|
||||||
|
raise Exception('Please set CORE_LAYER_NAME in settings.py')
|
||||||
|
core_layerbranch = LayerBranch.objects.filter(layer__name=settings.CORE_LAYER_NAME).first()
|
||||||
|
if not core_layerbranch:
|
||||||
|
raise Exception('Unable to find core layer "%s" specified in CORE_LAYER_NAME in settings.py' % settings.CORE_LAYER_NAME)
|
||||||
|
for row in RecipeUpstreamHistory.objects.all():
|
||||||
|
row.layerbranch = core_layerbranch
|
||||||
|
row.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('rrs', '0012_reup_layerbranch_field'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(populate_layerbranch, reverse_code=migrations.RunPython.noop),
|
||||||
|
]
|
19
rrs/migrations/0014_reup_layerbranch_nonnull.py
Normal file
19
rrs/migrations/0014_reup_layerbranch_nonnull.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('rrs', '0013_reup_layerbranch_populate'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='recipeupstreamhistory',
|
||||||
|
name='layerbranch',
|
||||||
|
field=models.ForeignKey(to='layerindex.LayerBranch'),
|
||||||
|
),
|
||||||
|
]
|
29
rrs/migrations/0015_rmh_layerbranch_populate.py
Normal file
29
rrs/migrations/0015_rmh_layerbranch_populate.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import settings
|
||||||
|
|
||||||
|
|
||||||
|
def populate_rmh_layerbranch(apps, schema_editor):
|
||||||
|
RecipeMaintainerHistory = apps.get_model('rrs', 'RecipeMaintainerHistory')
|
||||||
|
LayerBranch = apps.get_model('layerindex', 'LayerBranch')
|
||||||
|
if not settings.CORE_LAYER_NAME:
|
||||||
|
raise Exception('Please set CORE_LAYER_NAME in settings.py')
|
||||||
|
core_layerbranch = LayerBranch.objects.filter(layer__name=settings.CORE_LAYER_NAME).first()
|
||||||
|
if not core_layerbranch:
|
||||||
|
raise Exception('Unable to find core layer "%s" specified in CORE_LAYER_NAME in settings.py - please set up the layerindex application first' % settings.CORE_LAYER_NAME)
|
||||||
|
for row in RecipeMaintainerHistory.objects.all():
|
||||||
|
row.layerbranch = core_layerbranch
|
||||||
|
row.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('rrs', '0014_reup_layerbranch_nonnull'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(populate_rmh_layerbranch, reverse_code=migrations.RunPython.noop),
|
||||||
|
]
|
19
rrs/migrations/0016_rmh_layerbranch_nonnull.py
Normal file
19
rrs/migrations/0016_rmh_layerbranch_nonnull.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('rrs', '0015_rmh_layerbranch_populate'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='recipemaintainerhistory',
|
||||||
|
name='layerbranch',
|
||||||
|
field=models.ForeignKey(to='layerindex.LayerBranch'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -218,11 +218,11 @@ class RecipeMaintainerHistory(models.Model):
|
||||||
date = models.DateTimeField(db_index=True)
|
date = models.DateTimeField(db_index=True)
|
||||||
author = models.ForeignKey(Maintainer)
|
author = models.ForeignKey(Maintainer)
|
||||||
sha1 = models.CharField(max_length=64, unique=True)
|
sha1 = models.CharField(max_length=64, unique=True)
|
||||||
layerbranch = models.ForeignKey(LayerBranch, blank=True, null=True)
|
layerbranch = models.ForeignKey(LayerBranch)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_last():
|
def get_last(layerbranch):
|
||||||
rmh_qry = RecipeMaintainerHistory.objects.filter().order_by('-date')
|
rmh_qry = RecipeMaintainerHistory.objects.filter(layerbranch=layerbranch).order_by('-date')
|
||||||
|
|
||||||
if rmh_qry:
|
if rmh_qry:
|
||||||
return rmh_qry[0]
|
return rmh_qry[0]
|
||||||
|
@ -230,14 +230,16 @@ class RecipeMaintainerHistory(models.Model):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_by_end_date(end_date):
|
def get_by_end_date(layerbranch, end_date):
|
||||||
rmh_qry = RecipeMaintainerHistory.objects.filter(
|
rmh_qry = RecipeMaintainerHistory.objects.filter(
|
||||||
|
layerbranch=layerbranch,
|
||||||
date__lte = end_date).order_by('-date')
|
date__lte = end_date).order_by('-date')
|
||||||
|
|
||||||
if rmh_qry:
|
if rmh_qry:
|
||||||
return rmh_qry[0]
|
return rmh_qry[0]
|
||||||
|
|
||||||
rmh_qry = RecipeMaintainerHistory.objects.filter(
|
rmh_qry = RecipeMaintainerHistory.objects.filter(
|
||||||
|
layerbranch=layerbranch
|
||||||
).order_by('date')
|
).order_by('date')
|
||||||
if rmh_qry:
|
if rmh_qry:
|
||||||
return rmh_qry[0]
|
return rmh_qry[0]
|
||||||
|
@ -267,12 +269,14 @@ class RecipeMaintainer(models.Model):
|
||||||
self.maintainer.email)
|
self.maintainer.email)
|
||||||
|
|
||||||
class RecipeUpstreamHistory(models.Model):
|
class RecipeUpstreamHistory(models.Model):
|
||||||
|
layerbranch = models.ForeignKey(LayerBranch)
|
||||||
start_date = models.DateTimeField(db_index=True)
|
start_date = models.DateTimeField(db_index=True)
|
||||||
end_date = models.DateTimeField(db_index=True)
|
end_date = models.DateTimeField(db_index=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_last_by_date_range(start, end):
|
def get_last_by_date_range(layerbranch, start, end):
|
||||||
history = RecipeUpstreamHistory.objects.filter(start_date__gte = start,
|
history = RecipeUpstreamHistory.objects.filter(layerbranch=layerbranch,
|
||||||
|
start_date__gte = start,
|
||||||
start_date__lte = end).order_by('-start_date')
|
start_date__lte = end).order_by('-start_date')
|
||||||
|
|
||||||
if history:
|
if history:
|
||||||
|
@ -281,8 +285,9 @@ class RecipeUpstreamHistory(models.Model):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_first_by_date_range(start, end):
|
def get_first_by_date_range(layerbranch, start, end):
|
||||||
history = RecipeUpstreamHistory.objects.filter(start_date__gte = start,
|
history = RecipeUpstreamHistory.objects.filter(layerbranch=layerbranch,
|
||||||
|
start_date__gte = start,
|
||||||
start_date__lte = end).order_by('start_date')
|
start_date__lte = end).order_by('start_date')
|
||||||
|
|
||||||
if history:
|
if history:
|
||||||
|
@ -291,8 +296,8 @@ class RecipeUpstreamHistory(models.Model):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_last():
|
def get_last(layerbranch):
|
||||||
history = RecipeUpstreamHistory.objects.filter().order_by('-start_date')
|
history = RecipeUpstreamHistory.objects.filter(layerbranch=layerbranch).order_by('-start_date')
|
||||||
|
|
||||||
if history:
|
if history:
|
||||||
return history[0]
|
return history[0]
|
||||||
|
|
|
@ -112,7 +112,7 @@ def maintainer_history(options, logger):
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for commit in commits.strip().split("\n"):
|
for commit in commits.strip().split("\n"):
|
||||||
if RecipeMaintainerHistory.objects.filter(sha1=commit):
|
if RecipeMaintainerHistory.objects.filter(layerbranch=layerbranch, sha1=commit):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.debug("Analysing commit %s ..." % (commit))
|
logger.debug("Analysing commit %s ..." % (commit))
|
||||||
|
@ -170,7 +170,7 @@ def maintainer_history(options, logger):
|
||||||
(recipe.pn, rms.sha1))
|
(recipe.pn, rms.sha1))
|
||||||
|
|
||||||
# set new recipes to no maintainer if don't have one
|
# set new recipes to no maintainer if don't have one
|
||||||
rms = RecipeMaintainerHistory.get_last()
|
rms = RecipeMaintainerHistory.get_last(layerbranch)
|
||||||
for recipe in layerbranch.recipe_set.all():
|
for recipe in layerbranch.recipe_set.all():
|
||||||
if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
|
if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
|
||||||
rm = RecipeMaintainer()
|
rm = RecipeMaintainer()
|
||||||
|
|
|
@ -159,12 +159,12 @@ def main():
|
||||||
for item in maintplan.maintenanceplanlayerbranch_set.all():
|
for item in maintplan.maintenanceplanlayerbranch_set.all():
|
||||||
layerbranch = item.layerbranch
|
layerbranch = item.layerbranch
|
||||||
|
|
||||||
recipe_upstream_history = RecipeUpstreamHistory.get_last()
|
recipe_upstream_history = RecipeUpstreamHistory.get_last(layerbranch)
|
||||||
if recipe_upstream_history is None:
|
if recipe_upstream_history is None:
|
||||||
logger.warn('I don\'t have Upstream information yet, run update.py script')
|
logger.warn('I don\'t have Upstream information yet, run update.py script')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
recipe_maintainer_history = RecipeMaintainerHistory.get_last()
|
recipe_maintainer_history = RecipeMaintainerHistory.get_last(layerbranch)
|
||||||
if recipe_maintainer_history is None:
|
if recipe_maintainer_history is None:
|
||||||
logger.warn('I don\'t have Maintainership information yet,' +
|
logger.warn('I don\'t have Maintainership information yet,' +
|
||||||
' run rrs_maintainer_history.py script')
|
' run rrs_maintainer_history.py script')
|
||||||
|
|
|
@ -199,7 +199,7 @@ if __name__=="__main__":
|
||||||
for recipe_data in recipes:
|
for recipe_data in recipes:
|
||||||
set_regexes(recipe_data)
|
set_regexes(recipe_data)
|
||||||
|
|
||||||
history = RecipeUpstreamHistory(start_date = datetime.now())
|
history = RecipeUpstreamHistory(layerbranch=layerbranch, start_date=datetime.now())
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for recipe_data in recipes:
|
for recipe_data in recipes:
|
||||||
|
|
297
rrs/views.py
297
rrs/views.py
|
@ -114,7 +114,7 @@ class Raw():
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_reup_statistics(date, date_id):
|
def get_reup_statistics(maintplan, date, date_id):
|
||||||
""" Special case to get recipes statistics removing gcc-source duplicates """
|
""" Special case to get recipes statistics removing gcc-source duplicates """
|
||||||
recipes = []
|
recipes = []
|
||||||
updated = 0
|
updated = 0
|
||||||
|
@ -122,11 +122,13 @@ class Raw():
|
||||||
cant = 0
|
cant = 0
|
||||||
unknown = 0
|
unknown = 0
|
||||||
|
|
||||||
all_recipes = Raw.get_reupg_by_date(date)
|
for maintplanlayer in maintplan.maintenanceplanlayerbranch_set.all():
|
||||||
for re in all_recipes:
|
layerbranch = maintplanlayer.layerbranch
|
||||||
recipes.append(re["id"])
|
layerbranch_recipes = Raw.get_reupg_by_date(layerbranch.id, date)
|
||||||
|
for re in layerbranch_recipes:
|
||||||
|
recipes.append(re["id"])
|
||||||
|
|
||||||
if date_id:
|
if date_id and recipes:
|
||||||
recipes = str(recipes).strip('[]')
|
recipes = str(recipes).strip('[]')
|
||||||
qry = """SELECT id, status, no_update_reason
|
qry = """SELECT id, status, no_update_reason
|
||||||
FROM rrs_recipeupstream"""
|
FROM rrs_recipeupstream"""
|
||||||
|
@ -166,14 +168,17 @@ class Raw():
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_reup_by_last_updated(date):
|
def get_reup_by_last_updated(layerbranch_id, date):
|
||||||
""" Get last time the Recipes were upgraded """
|
""" Get last time the Recipes were upgraded """
|
||||||
cur = connection.cursor()
|
cur = connection.cursor()
|
||||||
cur.execute("""SELECT recipe_id, MAX(commit_date) AS date
|
cur.execute("""SELECT recipe_id, MAX(commit_date) AS date
|
||||||
FROM rrs_recipeupgrade
|
FROM rrs_recipeupgrade
|
||||||
|
INNER JOIN layerindex_recipe AS re
|
||||||
|
ON rrs_recipeupgrade.recipe_id = re.id
|
||||||
WHERE commit_date <= %s
|
WHERE commit_date <= %s
|
||||||
|
AND re.layerbranch_id = %s
|
||||||
GROUP BY recipe_id;
|
GROUP BY recipe_id;
|
||||||
""", [date])
|
""", [date, layerbranch_id])
|
||||||
return Raw.dictfetchall(cur)
|
return Raw.dictfetchall(cur)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -188,7 +193,7 @@ class Raw():
|
||||||
return [i[0] for i in cur.fetchall()]
|
return [i[0] for i in cur.fetchall()]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_reupg_by_date(date):
|
def get_reupg_by_date(layerbranch_id, date):
|
||||||
""" Get info for Recipes for the milestone """
|
""" Get info for Recipes for the milestone """
|
||||||
cur = connection.cursor()
|
cur = connection.cursor()
|
||||||
cur.execute("""SELECT re.id, re.pn, re.summary, te.version, rownum FROM (
|
cur.execute("""SELECT re.id, re.pn, re.summary, te.version, rownum FROM (
|
||||||
|
@ -201,8 +206,9 @@ class Raw():
|
||||||
INNER JOIN layerindex_recipe AS re
|
INNER JOIN layerindex_recipe AS re
|
||||||
ON te.recipe_id = re.id
|
ON te.recipe_id = re.id
|
||||||
WHERE rownum = 1
|
WHERE rownum = 1
|
||||||
|
AND re.layerbranch_id = %s
|
||||||
ORDER BY re.pn;
|
ORDER BY re.pn;
|
||||||
""", [date])
|
""", [date, layerbranch_id])
|
||||||
return Raw.dictfetchall(cur)
|
return Raw.dictfetchall(cur)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -220,25 +226,27 @@ class Raw():
|
||||||
return Raw.dictfetchall(cur)
|
return Raw.dictfetchall(cur)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_remahi_by_end_date(date):
|
def get_remahi_by_end_date(layerbranch_id, date):
|
||||||
""" Get the latest Recipe Maintainer History for the milestone """
|
""" Get the latest Recipe Maintainer History for the milestone """
|
||||||
cur = connection.cursor()
|
cur = connection.cursor()
|
||||||
|
|
||||||
cur.execute("""SELECT id
|
cur.execute("""SELECT id
|
||||||
FROM rrs_recipemaintainerhistory
|
FROM rrs_recipemaintainerhistory
|
||||||
WHERE date <= %s
|
WHERE date <= %s
|
||||||
|
AND layerbranch_id = %s
|
||||||
ORDER BY date DESC
|
ORDER BY date DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
""", [str(date)])
|
""", [str(date), layerbranch_id])
|
||||||
|
|
||||||
ret = cur.fetchone()
|
ret = cur.fetchone()
|
||||||
|
|
||||||
if not ret:
|
if not ret:
|
||||||
cur.execute("""SELECT id
|
cur.execute("""SELECT id
|
||||||
FROM rrs_recipemaintainerhistory
|
FROM rrs_recipemaintainerhistory
|
||||||
|
WHERE layerbranch_id = %s
|
||||||
ORDER BY date
|
ORDER BY date
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
""")
|
""", [layerbranch_id])
|
||||||
ret = cur.fetchone()
|
ret = cur.fetchone()
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -256,88 +264,102 @@ class Raw():
|
||||||
def _get_milestone_statistics(milestone, maintainer_name=None):
|
def _get_milestone_statistics(milestone, maintainer_name=None):
|
||||||
milestone_statistics = {}
|
milestone_statistics = {}
|
||||||
|
|
||||||
recipe_upstream_history = RecipeUpstreamHistory.get_last_by_date_range(
|
milestone_statistics['all'] = 0
|
||||||
milestone.start_date,
|
milestone_statistics['up_to_date'] = 0
|
||||||
milestone.end_date
|
milestone_statistics['not_updated'] = 0
|
||||||
)
|
milestone_statistics['cant_be_updated'] = 0
|
||||||
recipe_upstream_history_first = \
|
milestone_statistics['unknown'] = 0
|
||||||
RecipeUpstreamHistory.get_first_by_date_range(
|
|
||||||
milestone.start_date,
|
|
||||||
milestone.end_date,
|
|
||||||
)
|
|
||||||
|
|
||||||
if maintainer_name is None:
|
if maintainer_name is None:
|
||||||
t_updated, t_not_updated, t_cant, t_unknown = \
|
|
||||||
Raw.get_reup_statistics(milestone.end_date, recipe_upstream_history)
|
|
||||||
milestone_statistics['all'] = \
|
|
||||||
t_updated + t_not_updated + t_cant + t_unknown
|
|
||||||
milestone_statistics['up_to_date'] = t_updated
|
|
||||||
milestone_statistics['not_updated'] = t_not_updated
|
|
||||||
milestone_statistics['cant_be_updated'] = t_cant
|
|
||||||
milestone_statistics['unknown'] = t_unknown
|
|
||||||
milestone_statistics['percentage'] = 0
|
|
||||||
milestone_statistics['all_upgraded'] = 0
|
milestone_statistics['all_upgraded'] = 0
|
||||||
milestone_statistics['all_not_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:
|
for maintplanlayer in milestone.release.plan.maintenanceplanlayerbranch_set.all():
|
||||||
recipes_not_upgraded = \
|
layerbranch = maintplanlayer.layerbranch
|
||||||
Raw.get_reup_by_date(recipe_upstream_history_first.id)
|
|
||||||
if recipes_not_upgraded:
|
recipe_upstream_history = RecipeUpstreamHistory.get_last_by_date_range(
|
||||||
recipes_upgraded = \
|
layerbranch,
|
||||||
Raw.get_reupg_by_dates_and_recipes(
|
milestone.start_date,
|
||||||
milestone.start_date, milestone.end_date, recipes_not_upgraded)
|
milestone.end_date
|
||||||
milestone_statistics['percentage'] = "%.0f" % \
|
)
|
||||||
((float(len(recipes_upgraded)) * 100.0)
|
recipe_upstream_history_first = \
|
||||||
/float(len(recipes_not_upgraded)))
|
RecipeUpstreamHistory.get_first_by_date_range(
|
||||||
milestone_statistics['all_upgraded'] = len(recipes_upgraded)
|
layerbranch,
|
||||||
milestone_statistics['all_not_upgraded'] = len(recipes_not_upgraded)
|
milestone.start_date,
|
||||||
milestone_statistics['percentage_up_to_date'] = "%.0f" % \
|
milestone.end_date,
|
||||||
(float(milestone_statistics['up_to_date']) * 100.0 \
|
)
|
||||||
/float(milestone_statistics['all']))
|
|
||||||
milestone_statistics['percentage_not_updated'] = "%.0f" % \
|
if maintainer_name is None:
|
||||||
(float(milestone_statistics['not_updated']) * 100.0 \
|
t_updated, t_not_updated, t_cant, t_unknown = \
|
||||||
/float(milestone_statistics['all']))
|
Raw.get_reup_statistics(milestone.release.plan, milestone.end_date, recipe_upstream_history)
|
||||||
milestone_statistics['percentage_cant_be_updated'] = "%.0f" % \
|
milestone_statistics['all'] += \
|
||||||
(float(milestone_statistics['cant_be_updated']) * 100.0 \
|
t_updated + t_not_updated + t_cant + t_unknown
|
||||||
/float(milestone_statistics['all']))
|
milestone_statistics['up_to_date'] = +t_updated
|
||||||
milestone_statistics['percentage_unknown'] = "%.0f" % \
|
milestone_statistics['not_updated'] = +t_not_updated
|
||||||
(float(milestone_statistics['unknown']) * 100.0
|
milestone_statistics['cant_be_updated'] += t_cant
|
||||||
/float(milestone_statistics['all']))
|
milestone_statistics['unknown'] += t_unknown
|
||||||
|
|
||||||
|
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['all_upgraded'] += len(recipes_upgraded)
|
||||||
|
milestone_statistics['all_not_upgraded'] += len(recipes_not_upgraded)
|
||||||
|
|
||||||
else:
|
|
||||||
recipe_maintainer_history = Raw.get_remahi_by_end_date(
|
|
||||||
milestone.end_date)
|
|
||||||
recipe_maintainer_all = Raw.get_re_by_mantainer_and_date(
|
|
||||||
maintainer_name, recipe_maintainer_history[0])
|
|
||||||
milestone_statistics['all'] = len(recipe_maintainer_all)
|
|
||||||
if recipe_upstream_history:
|
|
||||||
recipe_upstream_all = Raw.get_reup_by_recipes_and_date(
|
|
||||||
recipe_maintainer_all, recipe_upstream_history.id)
|
|
||||||
else:
|
else:
|
||||||
recipe_upstream_all = Raw.get_reup_by_recipes_and_date(
|
recipe_maintainer_history = Raw.get_remahi_by_end_date(
|
||||||
recipe_maintainer_all)
|
layerbranch.id, milestone.end_date)
|
||||||
|
recipe_maintainer_all = Raw.get_re_by_mantainer_and_date(
|
||||||
milestone_statistics['up_to_date'] = 0
|
maintainer_name, recipe_maintainer_history[0])
|
||||||
milestone_statistics['not_updated'] = 0
|
milestone_statistics['all'] += len(recipe_maintainer_all)
|
||||||
milestone_statistics['cant_be_updated'] = 0
|
if recipe_upstream_history:
|
||||||
milestone_statistics['unknown'] = 0
|
recipe_upstream_all = Raw.get_reup_by_recipes_and_date(
|
||||||
for ru in recipe_upstream_all:
|
recipe_maintainer_all, recipe_upstream_history.id)
|
||||||
if ru['status'] == 'Y':
|
|
||||||
milestone_statistics['up_to_date'] += 1
|
|
||||||
elif ru['status'] == 'N':
|
|
||||||
if ru['no_update_reason'] == '':
|
|
||||||
milestone_statistics['not_updated'] += 1
|
|
||||||
else:
|
|
||||||
milestone_statistics['cant_be_updated'] += 1
|
|
||||||
else:
|
else:
|
||||||
milestone_statistics['unknown'] += 1
|
recipe_upstream_all = Raw.get_reup_by_recipes_and_date(
|
||||||
if milestone_statistics['all'] == 0:
|
recipe_maintainer_all)
|
||||||
milestone_statistics['percentage'] = '0'
|
|
||||||
|
for ru in recipe_upstream_all:
|
||||||
|
if ru['status'] == 'Y':
|
||||||
|
milestone_statistics['up_to_date'] += 1
|
||||||
|
elif ru['status'] == 'N':
|
||||||
|
if ru['no_update_reason'] == '':
|
||||||
|
milestone_statistics['not_updated'] += 1
|
||||||
|
else:
|
||||||
|
milestone_statistics['cant_be_updated'] += 1
|
||||||
|
else:
|
||||||
|
milestone_statistics['unknown'] += 1
|
||||||
|
|
||||||
|
|
||||||
|
milestone_statistics['percentage'] = '0'
|
||||||
|
if maintainer_name is None:
|
||||||
|
if milestone_statistics['all'] > 0:
|
||||||
|
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']))
|
||||||
|
if milestone_statistics['all_not_upgraded'] > 0:
|
||||||
|
milestone_statistics['percentage'] = "%.0f" % \
|
||||||
|
((float(milestone_statistics['all_upgraded']) * 100.0)
|
||||||
|
/float(milestone_statistics['all_not_upgraded']))
|
||||||
else:
|
else:
|
||||||
|
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"
|
||||||
|
else:
|
||||||
|
if milestone_statistics['all'] > 0:
|
||||||
milestone_statistics['percentage'] = "%.0f" % \
|
milestone_statistics['percentage'] = "%.0f" % \
|
||||||
((float(milestone_statistics['up_to_date']) /
|
((float(milestone_statistics['up_to_date']) /
|
||||||
float(milestone_statistics['all'])) * 100)
|
float(milestone_statistics['all'])) * 100)
|
||||||
|
@ -361,14 +383,6 @@ class RecipeList():
|
||||||
self.summary = summary
|
self.summary = summary
|
||||||
|
|
||||||
def _get_recipe_list(milestone):
|
def _get_recipe_list(milestone):
|
||||||
recipe_maintainer_history = Raw.get_remahi_by_end_date(
|
|
||||||
milestone.end_date)
|
|
||||||
|
|
||||||
recipe_upstream_history = RecipeUpstreamHistory.get_last_by_date_range(
|
|
||||||
milestone.start_date,
|
|
||||||
milestone.end_date
|
|
||||||
)
|
|
||||||
|
|
||||||
recipe_list = []
|
recipe_list = []
|
||||||
recipes_ids = []
|
recipes_ids = []
|
||||||
recipe_upstream_dict_all = {}
|
recipe_upstream_dict_all = {}
|
||||||
|
@ -376,29 +390,41 @@ def _get_recipe_list(milestone):
|
||||||
maintainers_dict_all = {}
|
maintainers_dict_all = {}
|
||||||
current_date = date.today()
|
current_date = date.today()
|
||||||
|
|
||||||
recipes = Raw.get_reupg_by_date(milestone.end_date)
|
for maintplanlayer in milestone.release.plan.maintenanceplanlayerbranch_set.all():
|
||||||
for i,re in enumerate(recipes):
|
layerbranch = maintplanlayer.layerbranch
|
||||||
if 'pv' in re:
|
|
||||||
recipes[i]['version'] = re['pv']
|
|
||||||
recipes_ids.append(re['id'])
|
|
||||||
|
|
||||||
if recipes:
|
recipe_maintainer_history = Raw.get_remahi_by_end_date(layerbranch.id,
|
||||||
recipe_last_updated = Raw.get_reup_by_last_updated(
|
milestone.end_date)
|
||||||
milestone.end_date)
|
|
||||||
for rela in recipe_last_updated:
|
|
||||||
recipe_last_updated_dict_all[rela['recipe_id']] = rela
|
|
||||||
|
|
||||||
if recipe_upstream_history:
|
recipe_upstream_history = RecipeUpstreamHistory.get_last_by_date_range(
|
||||||
recipe_upstream_all = Raw.get_reup_by_recipes_and_date(
|
layerbranch,
|
||||||
recipes_ids, recipe_upstream_history.id)
|
milestone.start_date,
|
||||||
for reup in recipe_upstream_all:
|
milestone.end_date
|
||||||
recipe_upstream_dict_all[reup['recipe_id']] = reup
|
)
|
||||||
|
|
||||||
if recipe_maintainer_history:
|
recipes = Raw.get_reupg_by_date(layerbranch.id, milestone.end_date)
|
||||||
maintainers_all = Raw.get_ma_by_recipes_and_date(
|
for i,re in enumerate(recipes):
|
||||||
recipes_ids, recipe_maintainer_history[0])
|
if 'pv' in re:
|
||||||
for ma in maintainers_all:
|
recipes[i]['version'] = re['pv']
|
||||||
maintainers_dict_all[ma['recipe_id']] = ma['name']
|
recipes_ids.append(re['id'])
|
||||||
|
|
||||||
|
if recipes:
|
||||||
|
recipe_last_updated = Raw.get_reup_by_last_updated(
|
||||||
|
layerbranch.id, milestone.end_date)
|
||||||
|
for rela in recipe_last_updated:
|
||||||
|
recipe_last_updated_dict_all[rela['recipe_id']] = rela
|
||||||
|
|
||||||
|
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:
|
for recipe in recipes:
|
||||||
upstream_version = ''
|
upstream_version = ''
|
||||||
|
@ -491,8 +517,11 @@ class RecipeListView(ListView):
|
||||||
|
|
||||||
self.milestone_statistics = _get_milestone_statistics(milestone)
|
self.milestone_statistics = _get_milestone_statistics(milestone)
|
||||||
|
|
||||||
self.recipe_maintainer_history = RecipeMaintainerHistory.get_by_end_date(
|
self.recipe_maintainer_history = {}
|
||||||
milestone.end_date)
|
for maintplanlayer in maintplan.maintenanceplanlayerbranch_set.all():
|
||||||
|
layerbranch = maintplanlayer.layerbranch
|
||||||
|
self.recipe_maintainer_history[layerbranch.id] = RecipeMaintainerHistory.get_by_end_date(layerbranch,
|
||||||
|
milestone.end_date)
|
||||||
|
|
||||||
recipe_list = _get_recipe_list(milestone)
|
recipe_list = _get_recipe_list(milestone)
|
||||||
self.recipe_list_count = len(recipe_list)
|
self.recipe_list_count = len(recipe_list)
|
||||||
|
@ -538,12 +567,12 @@ class RecipeListView(ListView):
|
||||||
context['maintainer_name'] = self.maintainer_name
|
context['maintainer_name'] = self.maintainer_name
|
||||||
context['set_maintainers'] = ['All', 'No maintainer']
|
context['set_maintainers'] = ['All', 'No maintainer']
|
||||||
all_maintainers = []
|
all_maintainers = []
|
||||||
for rm in RecipeMaintainer.objects.filter(history =
|
for layerbranch_id, rmh in self.recipe_maintainer_history.items():
|
||||||
self.recipe_maintainer_history).values(
|
for rm in RecipeMaintainer.objects.filter(history=rmh).values(
|
||||||
'maintainer__name').distinct().order_by('maintainer__name'):
|
'maintainer__name').distinct().order_by('maintainer__name'):
|
||||||
if rm['maintainer__name'] in context['set_maintainers']:
|
if rm['maintainer__name'] in context['set_maintainers']:
|
||||||
continue
|
continue
|
||||||
all_maintainers.append(rm['maintainer__name'])
|
all_maintainers.append(rm['maintainer__name'])
|
||||||
context['all_maintainers'] = all_maintainers
|
context['all_maintainers'] = all_maintainers
|
||||||
|
|
||||||
context['search'] = self.search
|
context['search'] = self.search
|
||||||
|
@ -608,6 +637,7 @@ def _get_recipe_upgrade_detail(maintplan, recipe_upgrade):
|
||||||
if milestone:
|
if milestone:
|
||||||
milestone_name = milestone.name
|
milestone_name = milestone.name
|
||||||
recipe_maintainer_history = RecipeMaintainerHistory.get_by_end_date(
|
recipe_maintainer_history = RecipeMaintainerHistory.get_by_end_date(
|
||||||
|
recipe_upgrade.recipe.layerbranch,
|
||||||
milestone.end_date)
|
milestone.end_date)
|
||||||
|
|
||||||
is_recipe_maintainer = False
|
is_recipe_maintainer = False
|
||||||
|
@ -655,6 +685,7 @@ class RecipeDetailView(DetailView):
|
||||||
context['upstream_version'] = ''
|
context['upstream_version'] = ''
|
||||||
context['upstream_no_update_reason'] = ''
|
context['upstream_no_update_reason'] = ''
|
||||||
recipe_upstream_history = RecipeUpstreamHistory.get_last_by_date_range(
|
recipe_upstream_history = RecipeUpstreamHistory.get_last_by_date_range(
|
||||||
|
recipe.layerbranch,
|
||||||
milestone.start_date,
|
milestone.start_date,
|
||||||
milestone.end_date
|
milestone.end_date
|
||||||
)
|
)
|
||||||
|
@ -671,7 +702,7 @@ class RecipeDetailView(DetailView):
|
||||||
context['upstream_version'] = recipe_upstream.version
|
context['upstream_version'] = recipe_upstream.version
|
||||||
context['upstream_no_update_reason'] = recipe_upstream.no_update_reason
|
context['upstream_no_update_reason'] = recipe_upstream.no_update_reason
|
||||||
|
|
||||||
self.recipe_maintainer_history = RecipeMaintainerHistory.get_last()
|
self.recipe_maintainer_history = RecipeMaintainerHistory.get_last(recipe.layerbranch)
|
||||||
recipe_maintainer = RecipeMaintainer.objects.filter(recipe = recipe,
|
recipe_maintainer = RecipeMaintainer.objects.filter(recipe = recipe,
|
||||||
history = self.recipe_maintainer_history)
|
history = self.recipe_maintainer_history)
|
||||||
if recipe_maintainer:
|
if recipe_maintainer:
|
||||||
|
@ -737,16 +768,20 @@ class MaintainerListView(ListView):
|
||||||
|
|
||||||
self.milestone_statistics = _get_milestone_statistics(milestone)
|
self.milestone_statistics = _get_milestone_statistics(milestone)
|
||||||
|
|
||||||
recipe_maintainer_history = RecipeMaintainerHistory.get_by_end_date(
|
self.maintainer_count = 0
|
||||||
milestone.end_date)
|
for maintplanlayer in maintplan.maintenanceplanlayerbranch_set.all():
|
||||||
|
layerbranch = maintplanlayer.layerbranch
|
||||||
|
|
||||||
if recipe_maintainer_history:
|
recipe_maintainer_history = RecipeMaintainerHistory.get_by_end_date(
|
||||||
for rm in RecipeMaintainer.objects.filter(history =
|
layerbranch, milestone.end_date)
|
||||||
recipe_maintainer_history).values(
|
|
||||||
'maintainer__name').distinct().order_by('maintainer__name'):
|
|
||||||
maintainer_list.append(MaintainerList(rm['maintainer__name']))
|
|
||||||
|
|
||||||
self.maintainer_count = len(maintainer_list)
|
if recipe_maintainer_history:
|
||||||
|
for rm in RecipeMaintainer.objects.filter(history =
|
||||||
|
recipe_maintainer_history).values(
|
||||||
|
'maintainer__name').distinct().order_by('maintainer__name'):
|
||||||
|
maintainer_list.append(MaintainerList(rm['maintainer__name']))
|
||||||
|
|
||||||
|
self.maintainer_count += len(maintainer_list)
|
||||||
|
|
||||||
self.intervals = sorted(intervals.keys())
|
self.intervals = sorted(intervals.keys())
|
||||||
current_date = date.today()
|
current_date = date.today()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user