Give tips a date, a scope per child, and a dismissal that sticks

Three faults, all invisible while the tests passed. Advice was built for the
first child only, so a second child got none. The planned days feeding every
count were fetched once per parent and appended to one list, so a couple's
days were counted twice and every intensity and projection derived from them
was wrong. And dismissing a tip forgot the moment the page reloaded.

Tips now carry the date they concern, lifted from figures the rules already
computed, so a view of a month can show only what applies to it. They are
built per child and identified per child, so the same rule firing for two
children is two separate pieces of advice.

A dismissal is stored against a fingerprint of the facts that were dismissed.
When those facts change the advice returns with its new numbers, rather than
one click silencing a warning about a forfeiture that keeps growing.
This commit is contained in:
2026-09-17 22:32:03 +02:00
parent c15cd44cb4
commit fdbfb7d580
20 changed files with 1396 additions and 57 deletions
@@ -0,0 +1,21 @@
"""Abstract repository interface for TipDismissal.
Adds entity-specific queries on top of the generic CRUD contract. Concrete
implementations live in app/repositories_impl/<backend>/.
"""
from abc import abstractmethod
from uuid import UUID
from app.entities.tip_dismissal import TipDismissal
from app.repositories.base import Repository
class TipDismissalRepository(Repository[TipDismissal]):
@abstractmethod
async def get_by_workspace_tip(self, workspace_id: UUID, tip_id: str) -> TipDismissal | None:
"""Return the dismissal for a given workspace + tip id (UNIQUE), or None."""
@abstractmethod
async def list_by_workspace(self, workspace_id: UUID) -> list[TipDismissal]:
"""Return all dismissals for a workspace."""