=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===

This commit is contained in:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
@@ -17,6 +17,7 @@ namespace adas_core.Infrastructure.Repositories;
/// Repository implementation for managing Display entities in MongoDB.
/// Provides CRUD operations and specialized queries for display devices.
/// </summary>
/// <!-- aidoc:v1 sig=4489fa0 -->
public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
{
#region Properties
@@ -34,6 +35,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="apiSettings">API settings containing collection names configuration.</param>
/// <param name="database">The MongoDB database instance.</param>
/// <param name="logger">Logger for repository operations.</param>
/// <!-- aidoc:v1 sig=602ae85 body=8a9d2fd -->
public DisplayRepository(
IOptions<ApiSettings> apiSettings,
IMongoDatabase database,
@@ -53,6 +55,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// Creates the necessary indexes for the Display collection.
/// Creates indexes on displayConfigId and unitId fields for improved query performance.
/// </summary>
/// <!-- aidoc:v1 sig=4955da2 body=e61cb51 -->
public override async Task CreateIndexes()
{
var options = new CreateIndexOptions<Display> { Background = true, Unique = false };
@@ -74,6 +77,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// Gets the name of the collection for displays.
/// </summary>
/// <returns>The collection name from API settings.</returns>
/// <!-- aidoc:v1 sig=94e22ff body=1415d9e -->
public override string GetCollectionName()
{
return _apiSettings.Displays;
@@ -83,6 +87,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// Retrieves all displays from the database.
/// </summary>
/// <returns>A list of all Display entities.</returns>
/// <!-- aidoc:v1 sig=f108028 body=b55a64a -->
public async Task<List<Display>> GetAll()
{
var result = await Collection.Find(Builders<Display>.Filter.Empty).ToListAsync();
@@ -96,6 +101,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="filter">The pagination and filtering parameters.</param>
/// <returns>A fluent queryable for Display results.</returns>
/// <exception cref="BadRequestException">Thrown when the text filter exceeds 100 characters.</exception>
/// <!-- aidoc:v1 sig=2c97614 body=82ace38 -->
public IFindFluent<Display, Display> GetPaginatedDisplays(PaginationFilter filter)
{
var filterBuilder = Builders<Display>.Filter;
@@ -148,6 +154,8 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="filters">List of filter definitions to apply.</param>
/// <param name="sort">Sort definition for the query results.</param>
/// <returns>A fluent queryable for Display results.</returns>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The summary says 'paginated displays' but the code only performs Find and Sort with no Skip/Limit pagination logic." -->
private IFindFluent<Display, Display> CreateFindFluent(List<FilterDefinition<Display>> filters,
SortDefinition<Display> sort)
{
@@ -162,6 +170,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// </summary>
/// <param name="pointOfCare">The PointOfCare to filter by.</param>
/// <returns>A list of Display entities associated with the point of care.</returns>
/// <!-- aidoc:v1 sig=ad8af85 body=814934a -->
public async Task<List<Display>> GetByPointOfCare(PointOfCare pointOfCare)
{
var filter = Builders<Display>.Filter.AnyEq(x => x.PointOfCareIdList, pointOfCare.Id);
@@ -174,6 +183,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// </summary>
/// <param name="name">The name of the display to retrieve.</param>
/// <returns>The Display if found; otherwise, null.</returns>
/// <!-- aidoc:v1 sig=58df1bb body=fbf8613 -->
public async Task<Display?> GetByName(string name)
{
var result = await Collection.FindAsync(Builders<Display>.Filter.Eq(p => p.Name, name));
@@ -185,6 +195,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// </summary>
/// <param name="id">The ObjectId of the display to retrieve.</param>
/// <returns>The Display if found; otherwise, null.</returns>
/// <!-- aidoc:v1 sig=06fe2a7 body=9ea9cc7 -->
public async Task<Display?> GetById(ObjectId id)
{
var result = await Collection.FindAsync(Builders<Display>.Filter.Eq(p => p.Id, id));
@@ -197,6 +208,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// </summary>
/// <param name="id">The ObjectId of the display to retrieve.</param>
/// <returns>The Display with DisplayConfig populated if found; otherwise, null.</returns>
/// <!-- aidoc:v1 sig=9707594 body=ef3813d -->
public async Task<Display?> GetByIdWithConfigDisplay(ObjectId id)
{
var pipeline = new BsonDocument[]
@@ -225,6 +237,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// </summary>
/// <param name="id">The ObjectId of the unit.</param>
/// <returns>A list of Display entities associated with the unit.</returns>
/// <!-- aidoc:v1 sig=30d0bf1 body=d267dcd -->
public async Task<List<Display>> GetByUnitId(ObjectId id)
{
var filter = Builders<Display>.Filter.Eq(p => p.UnitId, id);
@@ -238,6 +251,8 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="unitId">The ObjectId of the unit.</param>
/// <returns>The count of displays for the unit, or 0 if an error occurs.</returns>
/// <exception cref="Exception">Logs errors and returns 0 on failure.</exception>
/// <!-- aidoc-review:v1 severity=medium kind=wrong_exception
/// "Method catches Exception internally and returns 0; it does not throw Exception. The <exception> tag misleads readers about thrown exceptions." -->
public async Task<long> CountByUnitId(ObjectId unitId)
{
try
@@ -256,6 +271,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// </summary>
/// <param name="id">The ObjectId of the display configuration.</param>
/// <returns>A list of Display entities using the specified configuration.</returns>
/// <!-- aidoc:v1 sig=55e6b45 body=769064e -->
public async Task<List<Display>> GetByConfigId(ObjectId id)
{
var result = await Collection.FindAsync(Builders<Display>.Filter.Eq(p => p.DisplayConfigId, id));
@@ -269,6 +285,8 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="configId">The ObjectId of the card configuration.</param>
/// <returns>A list of Display entities using the specified card config, or empty list on error.</returns>
/// <exception cref="Exception">Logs errors and returns empty list on failure.</exception>
/// <!-- aidoc-review:v1 severity=medium kind=extra_exception
/// "The <exception cref=\"Exception\"> tag documents an exception that the method catches internally and never propagates to callers; the method instead returns an empty list. Exception tags should describe exceptions thrown to the caller." -->
public async Task<List<Display>> GetByCardConfigId(ObjectId configId)
{
try
@@ -307,6 +325,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// </summary>
/// <param name="displayConfigId">The ObjectId of the display configuration to check.</param>
/// <returns>The count of displays using the configuration.</returns>
/// <!-- aidoc:v1 sig=fddd490 body=6e359c3 -->
public async Task<long> IsDisplayConfigInUse(ObjectId displayConfigId)
{
return await Collection.CountDocumentsAsync(
@@ -324,6 +343,8 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="listPocObId">The new list of point of care ObjectIds.</param>
/// <returns>The updated Display if successful; otherwise, null.</returns>
/// <exception cref="Exception">Logs errors and returns null on failure.</exception>
/// <!-- aidoc-review:v1 severity=high kind=wrong_exception
/// "Method catches all exceptions (catch (Exception e)) and returns null; no exception is actually thrown or propagated. The <exception cref=\"Exception\"> tag misleads readers into expecting the method to throw." -->
public async Task<Display?> UpdatePointOfCareList(ObjectId objectId, List<ObjectId> listPocObId)
{
try
@@ -349,6 +370,8 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="config">The new DisplayConfig to set.</param>
/// <returns>The updated Display if successful; otherwise, null.</returns>
/// <exception cref="Exception">Logs errors and returns null on failure.</exception>
/// <!-- aidoc-review:v1 severity=medium kind=extra_exception
/// "The catch block swallows all exceptions and returns null, so Exception is never propagated to the caller." -->
public async Task<Display?> UpdateConfig(ObjectId objectId, DisplayConfig config)
{
try
@@ -374,6 +397,8 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="displayConfigId">The new display configuration ObjectId to set.</param>
/// <returns>The updated Display if successful; otherwise, null.</returns>
/// <exception cref="Exception">Logs errors and returns null on failure.</exception>
/// <!-- aidoc-review:v1 severity=medium kind=extra_exception
/// "The method catches all exceptions internally and returns null; it never throws Exception, so documenting <exception cref=\"Exception\"> is misleading for callers." -->
public async Task<Display?> UpdateConfigId(ObjectId objectId, ObjectId displayConfigId)
{
try
@@ -399,6 +424,8 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="objectIdConfigDisplay">The ObjectId of the display configuration preset.</param>
/// <returns>The updated Display if successful; otherwise, null.</returns>
/// <exception cref="Exception">Logs errors and returns null on failure.</exception>
/// <!-- aidoc-review:v1 severity=high kind=wrong_exception
/// "The method catches Exception internally and never rethrows it, so <exception cref=\"Exception\"> misleads callers into expecting the exception to propagate. The method always returns null on failure rather than throwing." -->
public async Task<Display?> UpdateConfigPreset(ObjectId objectIdDisplay, ObjectId objectIdConfigDisplay)
{
try
@@ -424,6 +451,7 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="name">The new name for the display.</param>
/// <returns>The updated Display if successful.</returns>
/// <exception cref="Exception">Throws an exception if MongoDB update fails.</exception>
/// <!-- aidoc:v1 sig=0662978 body=870f296 -->
public async Task<Display> UpdateName(Display display, string name)
{
try
@@ -453,6 +481,8 @@ public class DisplayRepository : MongoRepository<Display>, IDisplayRepository
/// <param name="unitId">The ObjectId of the unit whose displays should be deleted.</param>
/// <returns>True if deletion was successful; otherwise, false.</returns>
/// <exception cref="Exception">Logs errors and returns false on failure.</exception>
/// <!-- aidoc-review:v1 severity=high kind=wrong_exception
/// "The method catches all exceptions internally via `catch (Exception e)` and never propagates them to the caller; documenting `Exception` as a thrown exception is misleading" -->
public async Task<bool> DeleteManyByUnitId(ObjectId unitId)
{
try