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
8 changes: 6 additions & 2 deletions src/vouch/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typing import Any

from .metrics import DEFAULT_STALE_DAYS, compute
from .models import ClaimStatus, ProposalStatus
from .models import ClaimStatus, PageStatus, ProposalStatus
from .page_filters import filter_pages
from .storage import KBStore

Expand Down Expand Up @@ -179,8 +179,12 @@ def build(
stale.sort(key=lambda pair: pair[0])
stale_rows = [row for _, row in stale[:limit]]

# archived pages are excluded for the same reason the stale loop above
# skips retired claims: a followup that has been archived is no longer
# something the reviewer is being asked to act on, and leaving it in the
# due list makes archiving decorative on the surface it matters most.
due_pages = filter_pages(
store.list_pages(),
[p for p in store.list_pages() if p.status is not PageStatus.ARCHIVED],
kind="followup",
before={"due_at": now.date().isoformat()},
)
Expand Down
19 changes: 19 additions & 0 deletions tests/test_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,25 @@ def test_build_limit_caps_sections(store: KBStore) -> None:
assert len(d.decisions) <= 1


def test_build_excludes_archived_followups(tmp_path: Path) -> None:
# the stale-claims loop right above the followup query skips retired
# claims; the followup query has no status predicate, so archiving a
# followup page left it showing up as due forever.
s = KBStore.init(tmp_path)
due = (NOW - timedelta(days=2)).date().isoformat()
for pid, status in (("fu-live", PageStatus.ACTIVE), ("fu-archived", PageStatus.ARCHIVED)):
s.put_page(
Page(
id=pid, title=pid, type="followup", status=status,
metadata={"due_at": due, "followup_status": "open"},
)
)

d = digest_mod.build(s, now=NOW)

assert [r.id for r in d.followups_due] == ["fu-live"]


def test_build_limit_caps_followups(tmp_path: Path) -> None:
# --limit documents that it caps every section including followups; seed
# more due-open followups than the limit and confirm the list is bounded
Expand Down
Loading