Vœu de compagnon : être affecté avec 0 à N autres bénévoles
Nouveau vœu sur la fiche du bénévole — « je voudrais être affecté avec tel(s) bénévole(s) » — pris en compte à la fois pour le rendre visible et par le solveur. Backend : - `VolunteerCompanionWish` (`volunteer_id`, `companion_id`, à sens unique, `CHECK (volunteer_id <> companion_id)`) — migration 0010. - API : `wished_companion_ids` sur `VolunteerCreate`/`Update`/`Read`, mêmes règles que les autres vœux (ids inconnus → 422 `volunteer.unknown` ; se souhaiter soi-même → 422 `volunteer.cannot_wish_self`). - Solveur (`engine.py`) : bonus (+25 par correspondance) si un des compagnons souhaités du candidat est déjà affecté (décision déjà prise) au créneau — cumulable si plusieurs compagnons sont présents. Comme les autres termes de l'objectif, un bonus/malus, jamais une contrainte. - Seed de démo : ~20 % des bénévoles ont un vœu de compagnon (couple, amis). Frontend : - Fiche bénévole (`ConfigVolunteers.tsx`) : sélecteur de compagnons (ajout et édition), avec une bulle d'aide expliquant le sens unique et l'effet sur le solveur — c'est ce qui « fait apparaître » le lien entre bénévoles. - Panneau d'affectation : badge « avec N compagnon(s) souhaité(s) » sur un candidat, et bonus correspondant dans le classement par défaut (`candidateChanceScore`). - Mock (`runSolver`) : même bonus, pour que la démonstration se comporte pareil que le vrai solveur. CLAUDE.md à jour (modèle de domaine, section 4, journal). Vérifié : 194 tests backend (dont 13 nouveaux), ruff, alembic check ; typecheck/lint/build/smoke frontend ; solveur testé en direct sur le jeu de démo reseedé (0,25 s, 47 suggestions). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uUsRg7XzopkCPWimwg9ZM
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
b97b95c606
commit
6a4bcf8782
@@ -127,9 +127,14 @@ export function AssignmentPanel({
|
||||
const assigned = useMemo(() => shiftAssignments.data ?? [], [shiftAssignments.data]);
|
||||
|
||||
// Raisons du score, par bénévole : vœu de poste, conflit avec un artiste
|
||||
// qu'il veut voir sur ce créneau (indépendant de sa disponibilité déclarée).
|
||||
// qu'il veut voir sur ce créneau (indépendant de sa disponibilité déclarée),
|
||||
// compagnons souhaités déjà affectés à ce créneau.
|
||||
const detailsByVolunteer = useMemo(() => {
|
||||
const map = new Map<string, { wishesPosition: boolean; conflictsWishedArtist: boolean }>();
|
||||
const assignedIds = new Set(assigned.map((a) => a.volunteer_id));
|
||||
const map = new Map<
|
||||
string,
|
||||
{ wishesPosition: boolean; conflictsWishedArtist: boolean; companionMatches: number }
|
||||
>();
|
||||
for (const v of volunteers.data ?? []) {
|
||||
const conflictsWishedArtist = v.artist_ids.some((id) => {
|
||||
const artist = artistsById.get(id);
|
||||
@@ -138,14 +143,16 @@ export function AssignmentPanel({
|
||||
map.set(v.id, {
|
||||
wishesPosition: v.wished_position_ids.includes(positionId),
|
||||
conflictsWishedArtist,
|
||||
companionMatches: v.wished_companion_ids.filter((id) => assignedIds.has(id)).length,
|
||||
});
|
||||
}
|
||||
return map;
|
||||
}, [volunteers.data, artistsById, shift, positionId]);
|
||||
}, [volunteers.data, artistsById, shift, positionId, assigned]);
|
||||
|
||||
// Score de chance de chaque candidat pour CE créneau : vœu de poste,
|
||||
// disponibilité (dont conflit avec un artiste qu'il veut voir), charge déjà
|
||||
// assignée — c'est ce qui classe la liste, pas juste « le moins chargé ».
|
||||
// disponibilité (dont conflit avec un artiste qu'il veut voir), compagnons
|
||||
// souhaités déjà présents, charge déjà assignée — c'est ce qui classe la
|
||||
// liste, pas juste « le moins chargé ».
|
||||
const scoreByVolunteer = useMemo(() => {
|
||||
const map = new Map<string, number>();
|
||||
for (const v of volunteers.data ?? []) {
|
||||
@@ -160,6 +167,7 @@ export function AssignmentPanel({
|
||||
shift.ends_at,
|
||||
),
|
||||
conflictsWishedArtist: details?.conflictsWishedArtist ?? false,
|
||||
companionMatches: details?.companionMatches ?? 0,
|
||||
assignedHours: hours.get(v.id) ?? 0,
|
||||
}),
|
||||
);
|
||||
@@ -280,6 +288,7 @@ export function AssignmentPanel({
|
||||
conflictsWishedArtist={
|
||||
detailsByVolunteer.get(volunteer.id)?.conflictsWishedArtist ?? false
|
||||
}
|
||||
companionMatches={detailsByVolunteer.get(volunteer.id)?.companionMatches ?? 0}
|
||||
suggested={suggestedIds.includes(volunteer.id)}
|
||||
resolvePosition={resolvePosition}
|
||||
/>
|
||||
@@ -303,6 +312,7 @@ function CandidateRow({
|
||||
coverage,
|
||||
wishesPosition,
|
||||
conflictsWishedArtist,
|
||||
companionMatches,
|
||||
suggested,
|
||||
resolvePosition,
|
||||
}: {
|
||||
@@ -313,6 +323,7 @@ function CandidateRow({
|
||||
coverage: Coverage;
|
||||
wishesPosition: boolean;
|
||||
conflictsWishedArtist: boolean;
|
||||
companionMatches: number;
|
||||
suggested: boolean;
|
||||
resolvePosition: (shiftId: string) => string | undefined;
|
||||
}) {
|
||||
@@ -379,9 +390,14 @@ function CandidateRow({
|
||||
{t('grille.panel.artistConflict')}
|
||||
</span>
|
||||
) : null}
|
||||
{companionMatches > 0 ? (
|
||||
<span className="inline-block border-[1.5px] border-ink bg-blue px-[6px] py-[3px] font-display text-[8.5px] font-extrabold uppercase tracking-wide">
|
||||
{t('grille.panel.withCompanion', { count: companionMatches })}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{blocking ? (
|
||||
{/* {blocking ? (
|
||||
<div className="flex items-stretch border-t-2 border-ink">
|
||||
<span className="flex w-[26px] flex-none items-center justify-center border-r-2 border-ink bg-hatch-orange font-display text-[12px] font-bold">
|
||||
⛔
|
||||
@@ -390,6 +406,14 @@ function CandidateRow({
|
||||
{t('grille.panel.blockingPrefix', { reason: violationText(blocking, resolvePosition) })}
|
||||
</span>
|
||||
</div>
|
||||
) : null} */}
|
||||
|
||||
{blocking ? (
|
||||
<div className="border-t-2 border-dashed border-ink bg-hatch-orange px-2 py-[6px]">
|
||||
<div className="font-display text-[8.5px] font-extrabold uppercase tracking-widest text-white">
|
||||
{t('grille.panel.blockingPrefix', { reason: violationText(blocking, resolvePosition) })}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{!isBlocked && warnings.length > 0 ? (
|
||||
|
||||
Reference in New Issue
Block a user