Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non legacy builders (<10.9) #119

Merged
merged 3 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/ports/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BuildHistoryFilter(django_filters.FilterSet):

class Meta:
model = BuildHistory
fields = ['builder_name__name']
fields = ['builder_name__display_name']


class PortFilterByMultiple(django_filters.FilterSet):
Expand Down
18 changes: 18 additions & 0 deletions app/ports/migrations/0010_builder_display_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2019-10-09 14:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('ports', '0009_alter_field_time_elapsed_buildhistory'),
]

operations = [
migrations.AddField(
model_name='builder',
name='display_name',
field=models.CharField(db_index=True, default='', max_length=20),
),
]
32 changes: 32 additions & 0 deletions app/ports/migrations/0011_populate_display_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 2.2.4 on 2019-10-09 14:19

from django.db import migrations


def add_new_builders(apps, schema_editor):
Builder = apps.get_model('ports', 'Builder')
Builder.objects.create(name='10.8_x86_64')
Builder.objects.create(name='10.7_x86_64')
Builder.objects.create(name='10.6_x86_64')
mojca marked this conversation as resolved.
Show resolved Hide resolved
Builder.objects.create(name='10.6_i386')


def populate_display_name_field(apps, schema_editor):
Builder = apps.get_model('ports', 'Builder')
for i in Builder.objects.all():
builder_name = str(i.name)
display_name = builder_name.replace('_x86_64', '').replace('_legacy', '')
i.display_name = display_name
i.save()


class Migration(migrations.Migration):

dependencies = [
('ports', '0010_builder_display_name'),
]

operations = [
migrations.RunPython(add_new_builders),
migrations.RunPython(populate_display_name_field)
]
2 changes: 2 additions & 0 deletions app/ports/models/buildhistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class Builder(models.Model):
name = models.CharField(max_length=100, db_index=True)
display_name = models.CharField(max_length=20, db_index=True, default='')


class BuildHistory(models.Model):
Expand All @@ -24,6 +25,7 @@ class BuildHistory(models.Model):
class Meta:
indexes = [
models.Index(fields=['port_name', 'builder_name', '-build_id']),
models.Index(fields=['port_name', 'builder_name', '-time_start']),
models.Index(fields=['port_name', 'status', 'builder_name']),
models.Index(fields=['port_name', 'builder_name']),
models.Index(fields=['-time_start']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h4 class="text-secondary">Showing {% if port_name != '' %}results for <i>"{{ po
{% for build in builds %}
<tr>
<td><a href="{% url 'port_detail' build.port_name %}">{{ build.port_name }}</a></td>
<td>{{ build.builder_name.name|os_version }}</td>
<td>{{ build.builder_name.display_name }}</td>
<td><a target="_blank" href="{% build_url build.builder_name.name build.build_id %}">{{ build.build_id }}</a></td>
<td>{{ build.time_start|date:"Y-m-d" }} {{ build.time_start|time:"G:i:s" }} </td>
<td>{{ build.time_elapsed }}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h4 class="text-secondary">Showing {% if status == "" %} <ins>All Builds</ins> {
</thead>
{% for build in builds %}
<tr>
<td>{{ build.builder_name.name|os_version }}</td>
<td>{{ build.builder_name.display_name }}</td>
<td><a target="_blank" href="{% build_url build.builder_name.name build.build_id %}">{{ build.build_id }}</a></td>
<td>{{ build.time_start|date:"Y-m-d" }} {{ build.time_start|time:"G:i:s" }} </td>
<td>{{ build.time_elapsed }}</td>
Expand Down
6 changes: 3 additions & 3 deletions app/ports/templates/ports/portdetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ <h5>Port Health:
{% for builder, latest_build in latest_builds.items %}
{% if latest_build %}
<a target="_blank"
href="{% build_url builder latest_build.build_id %}"><span class="mr-1 badge {% if latest_build.status == "build successful" %}
href="{% build_url latest_build.builder_name__name latest_build.build_id %}"><span class="mr-1 badge {% if latest_build.status == "build successful" %}
badge-success
{% else %}
badge-danger
{% endif %}">{{ builder|os_version }}</span></a>
{% endif %}">{{ builder }}</span></a>

{% else %}
<span class="badge badge-secondary mr-1">{{ builder|os_version }}</span>
<span class="badge badge-secondary mr-1">{{ builder }}</span>

{% endif %}
{% endfor %}</h5>
Expand Down
20 changes: 10 additions & 10 deletions app/ports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ def portdetail(request, name, slug="summary"):
if tab not in allowed_tabs:
return HttpResponse("Invalid tab requested. Expected values: {}".format(allowed_tabs))

all_latest_builds = BuildHistory.objects.all().order_by('port_name', 'builder_name', '-build_id').distinct('port_name', 'builder_name')
port_latest_builds = list(BuildHistory.objects.filter(id__in=Subquery(all_latest_builds.values('id')), port_name__iexact=name).values('builder_name__name', 'build_id', 'status'))
all_latest_builds = BuildHistory.objects.all().order_by('port_name', 'builder_name__display_name', '-time_start').distinct('port_name', 'builder_name__display_name')
port_latest_builds = list(BuildHistory.objects.filter(id__in=Subquery(all_latest_builds.values('id')), port_name__iexact=name).values('builder_name__name', 'builder_name__display_name', 'build_id', 'status'))

builders = list(Builder.objects.all().values_list('name', flat=True))
builders = list(Builder.objects.all().order_by('display_name').distinct('display_name').values_list('display_name', flat=True))

builders.sort(key=LooseVersion, reverse=True)
latest_builds = {}
for builder in builders:
latest_builds[builder] = next((item for item in port_latest_builds if item['builder_name__name'] == builder), False)
latest_builds[builder] = next((item for item in port_latest_builds if item['builder_name__display_name'] == builder), False)
return render(request, 'ports/portdetail.html', {
'req_port': req_port,
'latest_builds': latest_builds,
Expand Down Expand Up @@ -141,10 +141,10 @@ def portdetail_build_information(request):
builder = request.GET.get('builder_name__name', '')
port_name = request.GET.get('port_name', '')
page = request.GET.get('page', 1)
builders = list(Builder.objects.all().values_list('name', flat=True))
builders = list(Builder.objects.all().order_by('display_name').distinct('display_name').values_list('display_name', flat=True))
builders.sort(key=LooseVersion, reverse=True)
builds = BuildHistoryFilter({
'builder_name__name': builder,
'builder_name__display_name': builder,
'status': status,
}, queryset=BuildHistory.objects.filter(port_name__iexact=port_name).select_related('builder_name').order_by('-time_start')).qs
paginated_builds = Paginator(builds, 100)
Expand Down Expand Up @@ -214,7 +214,7 @@ def portdetail_stats(request):


def all_builds_view(request):
builders = list(Builder.objects.all().values_list('name', flat=True))
builders = list(Builder.objects.all().order_by('display_name').distinct('display_name').values_list('display_name', flat=True))
builders.sort(key=LooseVersion, reverse=True)
jump_to_page = request.GET.get('page', 1)

Expand All @@ -225,15 +225,15 @@ def all_builds_view(request):


def all_builds_filter(request):
builder = request.GET.get('builder_name__name')
builder = request.GET.get('builder_name__display_name')
status = request.GET.get('status')
port_name = request.GET.get('port_name')
page = request.GET.get('page')

if status == 'unresolved':
all_latest_builds = BuildHistory.objects.all().order_by('port_name', 'builder_name', '-build_id').distinct('port_name', 'builder_name')
all_latest_builds = BuildHistory.objects.all().order_by('port_name', 'builder_name__display_name', '-build_id').distinct('port_name', 'builder_name__display_name')
builds = BuildHistoryFilter({
'builder_name__name': builder,
'builder_name__display_name': builder,
'port_name': port_name,
}, queryset=BuildHistory.objects.filter(id__in=Subquery(all_latest_builds.values('id')), status__icontains='failed').select_related('builder_name').order_by('-time_start')).qs
else:
Expand Down
2 changes: 1 addition & 1 deletion app/static/js/ajax-all-builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function runAllBuildsAjax(page) {
type: 'GET',
url: '/ports/all_builds/filter/',
data: {
'builder_name__name': $('#builder-filter').val(),
'builder_name__display_name': $('#builder-filter').val(),
'status': $('#status-filter').val(),
'port_name': $('#name-filter').val(),
'page': page,
Expand Down