Thomas Fransolet 18e4240f0f RAG: pipeline d'ingestion, endpoints du guide IA, journalisation RGPD
Ingestion et indexation
- IIngestionService/IngestionService : chargement des collections filles par
  sous-type, un jeu de morceaux par langue, ChunkIndex continu.
- SectionIndexingInterceptor retenu comme unique déclencheur : les 5
  sous-contrôleurs totalisaient 30 SaveChanges et 0 Enqueue, donc ajouter des
  points d'intérêt à une carte ne réindexait rien.
- HTML retiré avant l'embedding et lignes trop longues recoupées : sans cela un
  article dépassait l'entrée max du modèle et emportait son lot de 50 morceaux.
- Gabarits de LanguageInit filtrés, DistinctBy(Text) avant le Take : ils
  occupaient les cinq premiers résultats d'une recherche en néerlandais.

Endpoints du guide IA
- GET /api/Ai/knowledge/{id} : agrégats sur ContentEmbedding, donc sur ce qui
  est réellement indexé — compter les sections publiées serait plus flatteur et faux.
- GET /api/Ai/insights/{id} : miroir de GuideIaInsights côté manager-app, c'est
  l'écran qui a fixé la forme pour que le job de thèmes la remplisse.

RGPD
- VisitorQuestion journalisée dans AiController.Chat. HasAnswer se déduit des
  sources du retrieval, pas du texte : un repli poli ressemble à une réponse.
  L'écriture n'échoue jamais la réponse au visiteur.
- VisitorQuestionPurgeService, 90 jours, actif sans condition de configuration :
  une durée écrite dans les CGU n'est pas un réglage commercial.

Corrections
- Updateinstance ne recopiait pas les quotas du nouveau plan.
- CheckQuota ne bloquait ni ne comptait à quota 0 — IA gratuite non comptée.
- StoragePath et SizeBytes renseignés à Create, types URL exclus.

dotnet build 0 erreur, dotnet test 130/130.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 10:48:10 +02:00

173 lines
6.3 KiB
C#

using ManagerService.DTOs;
using ManagerService.Helpers;
using NetTopologySuite.Geometries;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using static ManagerService.Data.SectionText;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section event
/// </summary>
public class SectionEvent : Section
{
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public string? BaseSectionMapId { get; set; }
[ForeignKey(nameof(BaseSectionMapId))]
public SectionMap? BaseMap { get; set; }
public List<MapAnnotation> GlobalMapAnnotations { get; set; } = new();
public List<ProgrammeBlock> Programme { get; set; } = new();
[Column(TypeName = "jsonb")]
public List<string> ParcoursIds { get; set; } = new(); // Liens vers GeoPoints spécifiques
public override string GetEmbeddableText(string language) =>
JoinText(new[]
{
BaseText(language),
StartDate.HasValue ? $"{StartDate:yyyy-MM-dd} → {EndDate:yyyy-MM-dd}" : null
}
.Concat((Programme ?? new List<ProgrammeBlock>())
.OrderBy(b => b.StartTime)
.SelectMany(b => new[]
{
Translate(b.Title, language),
Translate(b.Description, language)
}))
.Concat((GlobalMapAnnotations ?? new List<MapAnnotation>())
.Select(a => Translate(a.Label, language)))
.ToArray());
public override IEnumerable<string> GetReferencedResourceIds(string language = null) =>
BaseResourceIds()
.Concat((GlobalMapAnnotations ?? new List<MapAnnotation>())
.SelectMany(a => ResourceId(a.IconResourceId)))
.Concat((Programme ?? new List<ProgrammeBlock>())
.SelectMany(b => b.MapAnnotations ?? new List<MapAnnotation>())
.SelectMany(a => ResourceId(a.IconResourceId)));
public class ProgrammeBlock
{
[Key]
public string Id { get; set; }
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public List<MapAnnotation> MapAnnotations { get; set; }
public ProgrammeBlockDTO ToDTO()
{
return new ProgrammeBlockDTO
{
id = this.Id,
title = this.Title,
description = this.Description,
startTime = this.StartTime,
endTime = this.EndTime,
mapAnnotations = this.MapAnnotations?.Select(ma => ma.ToDTO()).ToList()
};
}
public ProgrammeBlock FromDTO(ProgrammeBlockDTO dto)
{
Title = dto.title;
Description = dto.description;
StartTime = dto.startTime;
EndTime = dto.endTime;
//MapAnnotations = dto.MapAnnotations?.Select(ma => new MapAnnotation.FromDTO(ma)).ToList() // Other method
return this;
}
}
public class MapAnnotation
{
[Key]
public string Id { get; set; }
public string? SectionEventId { get; set; } // FK for global event-level annotation (null = block annotation)
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Type { get; set; } // "first_aid", "parking", etc.
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Label { get; set; }
public GeometryType GeometryType { get; set; }
public Geometry Geometry { get; set; } // Peut être Point, LineString, Polygon
public string PolyColor { get; set; }
public string Icon { get; set; } // icon material if point
public string IconResourceId { get; set; } // Icon resource id
public Resource IconResource { get; set; } // Icon resource
public MapAnnotationDTO ToDTO()
{
return new MapAnnotationDTO
{
id = Id,
type = Type,
label = Label,
geometryType = GeometryType,
geometry = Geometry.ToDto(),
polyColor = PolyColor,
icon = Icon,
iconResourceId = IconResourceId,
iconResource = IconResource?.ToDTO()
};
}
public MapAnnotation FromDTO(MapAnnotationDTO dto)
{
Type = dto.type;
Label = dto.label;
GeometryType = dto.geometryType;
Geometry = dto.geometry.FromDto();
PolyColor = dto.polyColor;
Icon = dto.icon;
IconResourceId = dto.iconResourceId;
//IconResource = dto.IconResource?.ToModel()
return this;
}
}
public enum GeometryType
{
Point,
Polyline,
Circle,
Polygon
}
/*public EventDTO ToDTO()
{
return new EventDTO()
{
id = Id,
label = Label,
title = Title.ToList(),
description = Description.ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
};
}*/
}
}