Browse Source

Add metric for back-and-forth warnings

merge-requests/106/head
Deimos 4 years ago
parent
commit
59b0f24e7b
  1. 4
      tildes/tildes/metrics.py
  2. 3
      tildes/tildes/views/api/web/comment.py

4
tildes/tildes/metrics.py

@ -15,6 +15,10 @@ from prometheus_client import Counter, Histogram
_COUNTERS = {
"votes": Counter("tildes_votes_total", "Votes", labelnames=["target_type"]),
"comments": Counter("tildes_comments_total", "Comments"),
"comment_back_and_forth_warnings": Counter(
"tildes_comment_back_and_forth_warnings_total",
"Comment Back-and-forth Warnings",
),
"comment_labels": Counter(
"tildes_comment_labels_total", "Comment Labels", labelnames=["label"]
),

3
tildes/tildes/views/api/web/comment.py

@ -14,6 +14,7 @@ from sqlalchemy.orm.exc import FlushError
from webargs.pyramidparser import use_kwargs
from tildes.enums import CommentLabelOption, CommentNotificationType, LogEventType
from tildes.metrics import incr_counter
from tildes.models.comment import (
Comment,
CommentBookmark,
@ -94,6 +95,7 @@ def post_comment_reply(request: Request, markdown: str) -> dict:
wait_mins = _reply_wait_minutes(request, request.user, parent_comment.user)
if wait_mins:
incr_counter("comment_back_and_forth_warnings")
raise HTTPUnprocessableEntity(
f"You can't reply to this user yet. Please wait {wait_mins} minutes."
)
@ -150,6 +152,7 @@ def get_comment_reply(request: Request) -> dict:
"""Get the reply form for a comment with Intercooler."""
wait_mins = _reply_wait_minutes(request, request.user, request.context.user)
if wait_mins:
incr_counter("comment_back_and_forth_warnings")
raise HTTPUnprocessableEntity(
f"You can't reply to this user yet. Please wait {wait_mins} minutes."
)

Loading…
Cancel
Save