FEAT-1b: Inzuchtkoeffizient endpoints via Wright path method
- PedigreeCalculator: pure, EF-free Wright path-method engine (recursive F_A,
per-common-ancestor contributions, generationsAvailable, cycle guards)
- InbreedingService: loads pedigree from ApplicationContext shadow FKs
(Gerbils.LitterId, Litters.FatherId/MotherId) into in-memory maps
- InbreedingController: GET /gerbils/{id}/inbreeding-coefficient,
POST /genetics/test-inbreeding (hypothetical pairing for Probeverpaarung)
- Injects ApplicationContext directly; no Program.cs change (Dwight owns it)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
39
GerbilManagerWebAPI/Controllers/InbreedingController.cs
Normal file
39
GerbilManagerWebAPI/Controllers/InbreedingController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using GerbilManagerWebAPI.DAL;
|
||||
using GerbilManagerWebAPI.Dtos;
|
||||
using GerbilManagerWebAPI.Genetics;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace GerbilManagerWebAPI.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Inbreeding-coefficient (Inzuchtkoeffizient) endpoints — both for an existing
|
||||
/// gerbil and for a hypothetical pairing (Probeverpaarung).
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
public class InbreedingController : ControllerBase
|
||||
{
|
||||
private readonly InbreedingService service;
|
||||
|
||||
// ApplicationContext is already registered in DI; the service is a thin,
|
||||
// dependency-free wrapper so it needs no separate registration in Program.cs.
|
||||
public InbreedingController(ApplicationContext db)
|
||||
{
|
||||
service = new InbreedingService(db);
|
||||
}
|
||||
|
||||
// GET /gerbils/{id}/inbreeding-coefficient
|
||||
[HttpGet("gerbils/{id}/inbreeding-coefficient")]
|
||||
public ActionResult<InbreedingResult> GetForGerbil(Guid id)
|
||||
{
|
||||
var result = service.ForGerbil(id);
|
||||
return result is null ? NotFound() : result;
|
||||
}
|
||||
|
||||
// POST /genetics/test-inbreeding
|
||||
[HttpPost("genetics/test-inbreeding")]
|
||||
public ActionResult<InbreedingResult> TestPairing(TestInbreedingDto dto)
|
||||
{
|
||||
return service.ForPairing(dto.FatherId, dto.MotherId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user