Skip to content

Commit

Permalink
Merge pull request #94 from Ensembl/display_fix_copy
Browse files Browse the repository at this point in the history
Fixed display bug for job failures. Fixed status to match latest vers…
  • Loading branch information
thomasmaurel authored Jul 27, 2020
2 parents 1cdf84a + 8fb9669 commit 4dca8c1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 37 deletions.
31 changes: 8 additions & 23 deletions ensembl_dbcopy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,37 +85,25 @@ def overall_status(self):
return 'Complete'
elif self.transfer_logs.count() > 0 and self.status=='Processing Requests':
return 'Running'
elif self.transfer_logs.count() > 0 and self.status=='Creating Requests':
return 'Submitted'
else:
return 'Submitted'
return 'Submitted'

@property
def detailed_status(self):
total_tables = self.transfer_logs.count()
table_copied = self.table_copied
progress = 0
status_msg='Submitted'
if table_copied and total_tables:
progress = (table_copied / total_tables) * 100
if progress == 100.0:
return {'status_msg': 'Complete', 'table_copied': table_copied, 'total_tables': total_tables,
'progress': progress}
status_msg='Complete'
elif total_tables > 0:
if self.status:
if (self.end_date and self.status=='Transfer Ended') or ('Try:' in self.status):
return {'status_msg': 'Failed', 'table_copied': table_copied, 'total_tables': total_tables,
'progress': progress}
status_msg='Failed'
if self.status=='Processing Requests':
return {'status_msg': 'Running', 'table_copied': table_copied, 'total_tables': total_tables,
'progress': progress}
if self.status=='Creating Requests':
return {'status_msg': 'Submitted', 'table_copied': table_copied, 'total_tables': total_tables,
'progress': progress}
else:
return {'status_msg': 'Submitted', 'table_copied': table_copied, 'total_tables': total_tables,
'progress': progress}
else:
return {'status_msg': 'Submitted', 'table_copied': table_copied, 'total_tables': total_tables,
status_msg='Running'
return {'status_msg': status_msg, 'table_copied': table_copied, 'total_tables': total_tables,
'progress': progress}

@property
Expand Down Expand Up @@ -158,12 +146,9 @@ def table_status(self):
elif self.job_id.status:
if (self.job_id.end_date and self.job_id.status=='Transfer Ended') or ('Try:' in self.job_id.status):
return 'Failed'
elif self.job_id.status == 'Creating Requests':
return 'Submitted'
else:
elif self.job_id.status == 'Processing Requests':
return 'Running'
else:
return 'Submitted'
return 'Submitted'


class Host(models.Model):
Expand Down
24 changes: 11 additions & 13 deletions ensembl_dbcopy/templates/admin/dbcopy/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
list</a>
<a href="{% url 'admin:ensembl_dbcopy_requestjob_add' %}" class="btn btn-secondary" role="button">Submit New
Copy</a>
{% if user.is_superuser %}
<a href="{% url 'ensembl_dbcopy:reset_failed_jobs' original.job_id %}" class="btn btn-secondary" role="button">Reset failed jobs</a>
{% endif %}
<a href="{% url 'admin:ensembl_dbcopy_requestjob_change' original.job_id %}" class="btn btn-secondary"
role="button">Refresh</a>
<a href="{% url 'admin:ensembl_dbcopy_requestjob_add' %}?from_request_job={{ original.pk }}"
Expand Down Expand Up @@ -56,12 +59,6 @@
{% endif %}
</div>
</div>
<div class="row">
<div class="col-sm-2">
<div class="tablekey">Job ID:</div>
</div>
<div class="col-sm-10 tablevalue">{{ original.job_id }}</div>
</div>
<div class="row">
<div class="col-sm-2">
<div class="tablekey">Target Hosts:</div>
Expand Down Expand Up @@ -146,13 +143,14 @@
{% for log in transfer_logs %}
{% if log.message %}
{% if log.table_status != 'Complete' %}
<tr class="border">
<td rowspan="2">
<div class="tablekey">Failure detail:</div>
</td>
<td class="">
<div class="col-sm-10 tablevalue Failed"> {{ log.table_schema }}.{{ log.table_name }}: {{ log.message }}</div>
</td>
<div class="p-3 my-3 border">
<div class="row">
<div class="col-sm-2">
<div class="tablekey">Failure detail:</div>
</div>
<div class="col-sm-10 tablevalue Failed"> {{ log.table_schema }}.{{ log.table_name }}: {{ log.message }}</div>
</div>
</div>
{% endif %}
{% endif %}
<tr>
Expand Down
3 changes: 2 additions & 1 deletion ensembl_dbcopy/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"""
from django.urls import path

from .views import group_choice
from .views import reset_failed_jobs,group_choice

app_name = 'ensembl_dbcopy'

urlpatterns = [
path('reset_failed_jobs/<uuid:job_id>', reset_failed_jobs, name='reset_failed_jobs'),
path('add', group_choice, name='group_choice'),
]
10 changes: 10 additions & 0 deletions ensembl_dbcopy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@

from ensembl_dbcopy.models import RequestJob, Group, Host

def reset_failed_jobs(request, *args, **kwargs):
job_id = kwargs['job_id']
request_job = RequestJob.objects.filter(job_id=job_id)
request_job.update(status='Manually Launched by Production team')
obj = request_job[0]
url = reverse('admin:%s_%s_change' % (obj._meta.app_label, obj._meta.model_name),
args=[obj.job_id])
messages.success(request, "All the failed jobs for %s have been successfully reset" % job_id)
return redirect(url)

def group_choice(request, *args, **kwargs):

host_id = request.POST.get("host_id")
Expand Down

0 comments on commit 4dca8c1

Please sign in to comment.