Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions backend/src/patchnotes/revise.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Turn a staff deny reason into a new pending line.

The reason stays on the staff review. It is not copied into the public note
unless staff wrote the replacement themselves. A line that should not be
published is left denied.
The reason is an instruction. It is not copied into the public note.
Only an explicit replacement, such as "say: Added a station", becomes the
line. Feedback that covers several points is handled for the whole week,
not here. A line that should not be published is left denied.
"""

from __future__ import annotations
Expand All @@ -28,15 +29,7 @@
r"(?i)\b(?:make (?:it|this)|move (?:it|this) to|this is|put (?:it|this) in)\b"
)
_QUOTED = re.compile(r"[\"“”']([^\"“”']{2,80})[\"“”']")
_COMPLAINT = re.compile(
r"(?i)\b("
r"don'?t|do not|dont|remove|drop|without|spoiler|secret|lore|hidden|"
r"vague|unclear|wrong|leak|leaks|reveal|reveals|mention|shorter|technical|"
r"bugfix|bug fix|internal"
r")\b"
)
_SKIP_PHRASES = frozenset({"it", "this", "that", "the line", "line", "this line"})
_ASK = re.compile(r"(?i)(\?\s*$|\b(can you|could you|would you)\b)")


def rewrite(section: str, body: str, reason: str) -> tuple[str, str] | None:
Expand All @@ -55,8 +48,6 @@ def rewrite(section: str, body: str, reason: str) -> tuple[str, str] | None:
return None
stripped = _strip_requested(text, note)
candidate = stripped if stripped is not None else text
if candidate == text and _looks_like_replacement(note):
candidate = note
return _accept(section, text, candidate, note)


Expand All @@ -78,13 +69,6 @@ def _explicit_replacement(reason: str) -> str | None:
return text or None


def _looks_like_replacement(reason: str) -> bool:
"""A finished player sentence can replace a line. A question cannot."""
if _COMPLAINT.search(reason) or _ASK.search(reason):
return False
return player_text(reason) is not None


def _section_of(reason: str, current: str) -> str:
if _SECTION_INTENT.search(reason) is None:
return current
Expand Down
16 changes: 12 additions & 4 deletions backend/src/patchnotes/test_revise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Deny reasons become a new line, or the line stays denied."""
"""Deny reasons become a new line only when staff give the replacement, or the line stays denied."""

from __future__ import annotations

Expand All @@ -19,9 +19,17 @@ def test_explicit_wording_replaces_the_line(self) -> None:
self.assertEqual(section, "new")
self.assertEqual(body, "Added a station")

def test_staff_sentence_is_the_new_line(self) -> None:
section, body = rewrite("adjusted", "Changed a price", "Lowered the station price")
self.assertEqual((section, body), ("adjusted", "Lowered the station price"))
def test_a_staff_sentence_is_not_the_new_line(self) -> None:
self.assertIsNone(rewrite("adjusted", "Changed a price", "Lowered the station price"))

def test_feedback_about_several_points_is_not_pasted_in(self) -> None:
self.assertIsNone(
rewrite(
"new",
"Custom masks can be skinned onto your character.",
"custom masks can be submitted via token, thats the important bit",
)
)

def test_drop_leaves_the_line_denied(self) -> None:
self.assertIsNone(rewrite("new", "Added a station", "Don't post this"))
Expand Down