forked from GithubBackups/healthchecks
Log page shows notice about reached ping log limit.
This commit is contained in:
parent
68fe11a41b
commit
57b813677a
@ -8,7 +8,8 @@ from hc.api.models import Channel, Check
|
|||||||
@admin.register(Profile)
|
@admin.register(Profile)
|
||||||
class ProfileAdmin(admin.ModelAdmin):
|
class ProfileAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ("id", "email", "reports_allowed", "next_report_date")
|
list_display = ("id", "email", "reports_allowed", "next_report_date",
|
||||||
|
"ping_log_limit")
|
||||||
search_fields = ["user__email"]
|
search_fields = ["user__email"]
|
||||||
|
|
||||||
def email(self, obj):
|
def email(self, obj):
|
||||||
|
@ -215,19 +215,24 @@ def log(request, code):
|
|||||||
|
|
||||||
# Fill in "missed ping" placeholders:
|
# Fill in "missed ping" placeholders:
|
||||||
expected_date = older.created + check.timeout
|
expected_date = older.created + check.timeout
|
||||||
limit = 0
|
n_blanks = 0
|
||||||
while expected_date + check.grace < newer.created and limit < 10:
|
while expected_date + check.grace < newer.created and n_blanks < 10:
|
||||||
wrapped.append({"placeholder_date": expected_date})
|
wrapped.append({"placeholder_date": expected_date})
|
||||||
expected_date = expected_date + check.timeout
|
expected_date = expected_date + check.timeout
|
||||||
limit += 1
|
n_blanks += 1
|
||||||
|
|
||||||
# Prepare early flag for next ping to come
|
# Prepare early flag for next ping to come
|
||||||
early = older.created + check.timeout > newer.created + check.grace
|
early = older.created + check.timeout > newer.created + check.grace
|
||||||
|
|
||||||
|
reached_limit = len(pings) > limit
|
||||||
|
|
||||||
wrapped.reverse()
|
wrapped.reverse()
|
||||||
ctx = {
|
ctx = {
|
||||||
"check": check,
|
"check": check,
|
||||||
"pings": wrapped
|
"pings": wrapped,
|
||||||
|
"num_pings": len(pings),
|
||||||
|
"limit": limit,
|
||||||
|
"show_limit_notice": reached_limit and settings.USE_PAYMENTS
|
||||||
}
|
}
|
||||||
|
|
||||||
return render(request, "front/log.html", ctx)
|
return render(request, "front/log.html", ctx)
|
||||||
|
@ -87,6 +87,17 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
{% if show_limit_notice and limit < 10000 %}
|
||||||
|
<p class="alert alert-info">
|
||||||
|
<strong>Showing last {{ limit }} pings.</strong>
|
||||||
|
Want to see more?
|
||||||
|
<a href="{% url 'hc-pricing' %}">
|
||||||
|
Upgrade your account!
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="alert alert-info">Log is empty. This check has not received any pings yet.</div>
|
<div class="alert alert-info">Log is empty. This check has not received any pings yet.</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user