Skip to content

Commit

Permalink
Add github commit compare URL to job request detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
Jongmassey committed Feb 21, 2024
1 parent 65a4c1b commit a5cbc7a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions jobserver/views/job_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ def get(self, request, *args, **kwargs):

is_missing_updates = incomplete and over_30_minutes_ago

previous = JobRequest.objects.previous(job_request)
compare_url = (
job_request.workspace.repo.get_compare_url(previous.sha, job_request.sha)
if previous
else None
)

context = {
"honeycomb_can_view_links": honeycomb_can_view_links,
"honeycomb_links": {},
Expand All @@ -243,6 +250,7 @@ def get(self, request, *args, **kwargs):
"job_request": job_request,
"jobs": jobs,
"project_yaml": self.get_project_yaml(job_request),
"compare_url": compare_url,
"user_can_cancel_jobs": can_cancel_jobs,
"view": self,
}
Expand Down
8 changes: 8 additions & 0 deletions templates/job_request/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,14 @@ <h1 class="text-3xl tracking-tight break-words font-bold text-slate-900 sm:text-
</dl>
{% /card %}

{% if compare_url %}
{% #card title="Previous Job Request" %}
{% #description_item title="Compare code" stacked=True %}
{% link href=compare_url text="View on GitHub" %}
{% /description_item %}
{% /card %}
{% endif %}

{% if honeycomb_can_view_links %}
{% #card title="Monitoring" subtitle="Honeycomb login required" %}
{% #list_group small=True %}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/jobserver/views/test_job_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def test_jobrequestdetail_with_permission(
request = rf.get("/")
request.user = user

with django_assert_num_queries(8):
with django_assert_num_queries(9):
response = JobRequestDetail.as_view()(
request,
project_slug=job_request.workspace.project.slug,
Expand Down

0 comments on commit a5cbc7a

Please sign in to comment.