mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:26:30 +00:00
Errors sending to UI
notifying client of AI model conversion
This commit is contained in:
@@ -20,7 +20,7 @@ using RabbitMQ.Stream.Client.Reliable;
|
||||
|
||||
namespace Azaion.Common.Services;
|
||||
|
||||
public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
public class AnnotationService : IAnnotationService, INotificationHandler<AnnotationsDeletedEvent>
|
||||
{
|
||||
private readonly IDbFactory _dbFactory;
|
||||
private readonly FailsafeAnnotationsProducer _producer;
|
||||
@@ -124,11 +124,17 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
var fName = originalMediaName.ToTimeName(time);
|
||||
var annotation = await _dbFactory.Run(async db =>
|
||||
{
|
||||
var ann = await db.Annotations.FirstOrDefaultAsync(x => x.Name == fName, token: token);
|
||||
var ann = await db.Annotations
|
||||
.LoadWith(x => x.Detections)
|
||||
.FirstOrDefaultAsync(x => x.Name == fName, token: token);
|
||||
|
||||
status = userRole.IsValidator() && source == SourceEnum.Manual
|
||||
? AnnotationStatus.Validated
|
||||
: AnnotationStatus.Created;
|
||||
|
||||
if (fromQueue && ann is { AnnotationStatus: AnnotationStatus.Validated })
|
||||
return ann;
|
||||
|
||||
await db.Detections.DeleteAsync(x => x.AnnotationName == fName, token: token);
|
||||
|
||||
if (ann != null)
|
||||
@@ -164,6 +170,9 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
return ann;
|
||||
});
|
||||
|
||||
if (fromQueue && annotation is { AnnotationStatus: AnnotationStatus.Validated })
|
||||
return annotation;
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
var img = System.Drawing.Image.FromStream(stream);
|
||||
@@ -219,4 +228,12 @@ public class AnnotationService : INotificationHandler<AnnotationsDeletedEvent>
|
||||
File.Delete(annotation.ThumbPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IAnnotationService
|
||||
{
|
||||
Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default);
|
||||
Task<Annotation> SaveAnnotation(string originalMediaName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default);
|
||||
Task ValidateAnnotations(List<Annotation> annotations, CancellationToken token = default);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user