Show 'seen in releases' in the UI

This commit is contained in:
Klaas van Schelven
2024-04-16 13:31:08 +02:00
parent 5ae0a8227f
commit a7c02a24e2
3 changed files with 43 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load static %}
{% load issues %}
{% block title %}{{ issue.title }} · {{ block.super }}{% endblock %}
{% block content %}
@@ -140,27 +141,38 @@
</div>
<div class="mb-4">
<div class="text-sm font-bold text-slate-500">Nr. of events</div>
<div class="text-sm font-bold text-slate-500">Nr. of events:</div>
<div>{{ issue.event_count }}</div>
</div>
{% if issue.event_count > 1 %}
<div class="mb-4">
<div class="text-sm font-bold text-slate-500">First seen</div>
<div class="text-sm font-bold text-slate-500">First seen:</div>
<div>{{ issue.first_seen|date:"j M G:i" }}</div>
</div>
<div>
<div class="text-sm font-bold text-slate-500">Last seen</div>
<div class="mb-4">
<div class="text-sm font-bold text-slate-500">Last seen:</div>
<div>{{ issue.last_seen|date:"j M G:i" }}</div>
</div>
{% else %}
<div>
<div class="text-sm font-bold text-slate-500">Seen at</div>
<div class="mb-4">
<div class="text-sm font-bold text-slate-500">Seen at:</div>
<div>{{ issue.first_seen|date:"j M G:i" }}</div>
</div>
{% endif %}
{% if issue.get_events_at %}
<div class="mb-4">
<div class="text-sm font-bold text-slate-500">Seen in releases:</div>
<div>
{% for version in issue.get_events_at %}
<span {% if version|issha %}class="font-mono"{% endif %}>{{ version|shortsha }}{% if not forloop.last %}</span>,{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>

View File

@@ -15,10 +15,6 @@ from issues.models import Issue, TurningPoint, TurningPointKind
RE_PACKAGE_VERSION = re.compile('((?P<package>.*)[@])?(?P<version>.*)')
# We don't actually parse for HEX yet (it's simply non-semver to us) but if we do we could use the following lengths:
# 12 | 16 | 20 | 32 | 40 | 64
def is_valid_semver(full_version):
try:
version = RE_PACKAGE_VERSION.match(full_version).groupdict()["version"]

View File

@@ -1,3 +1,4 @@
import re
from django import template
from pygments import highlight
from pygments.lexers import PythonLexer
@@ -89,3 +90,27 @@ def firstlineno(value):
if value.get("lineno") is None:
return None
return value['lineno'] - len(value.get('pre_context', []))
SHA_RE = re.compile(r"[0-9a-f]+")
@register.filter(name='issha')
def issha(value):
"""does this look like a sha?"""
if len(value) not in [12, 16, 20, 32, 40, 64]:
return False
if not SHA_RE.fullmatch(value):
return False
return True
@register.filter(name='shortsha')
def shortsha(value):
"""_if_ this value looks like a version hash, make it short"""
if not issha(value):
return value
return value[:12]