fix datasetexplorer view

save annotation with detections
fix sending to queue
This commit is contained in:
Alex Bezdieniezhnykh
2024-12-26 23:47:03 +02:00
parent 81dcb2a92e
commit 5fe46cd6f5
4 changed files with 24 additions and 15 deletions
+13 -5
View File
@@ -65,13 +65,15 @@ public class FailsafeAnnotationsProducer
.Where(x => x.Status == AnnotationStatus.Created)
.Select(x => new Message(MessagePackSerializer.Serialize(x)))
.ToList();
await _annotationProducer.Send(createdMessages, CompressionType.Gzip);
if (createdMessages.Any())
await _annotationProducer.Send(createdMessages, CompressionType.Gzip);
var validatedMessages = messagesChunk
.Where(x => x.Status == AnnotationStatus.Validated)
.Select(x => new Message(MessagePackSerializer.Serialize(x)))
.ToList();
await _annotationConfirmProducer.Send(validatedMessages, CompressionType.Gzip);
if (validatedMessages.Any())
await _annotationConfirmProducer.Send(validatedMessages, CompressionType.Gzip);
await _dbFactory.Run(async db =>
await db.AnnotationsQueue.DeleteAsync(aq => messagesChunk.Any(x => aq.Name == x.Name), token: cancellationToken));
@@ -80,10 +82,12 @@ public class FailsafeAnnotationsProducer
catch (Exception e)
{
_logger.LogError(e, e.Message);
await Task.Delay(TimeSpan.FromSeconds(30), cancellationToken);
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
}
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
}
}
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
}
}
@@ -91,7 +95,8 @@ public class FailsafeAnnotationsProducer
{
return await _dbFactory.Run(async db =>
{
var annotations = await db.AnnotationsQueue.Join(db.Annotations, aq => aq.Name, a => a.Name, (aq, a) => a)
var annotations = await db.AnnotationsQueue.Join(
db.Annotations.LoadWith(x => x.Detections), aq => aq.Name, a => a.Name, (aq, a) => a)
.ToListAsync(token: cancellationToken);
var messages = new List<AnnotationCreatedMessage>();
@@ -105,10 +110,13 @@ public class FailsafeAnnotationsProducer
CreatedRole = annotation.CreatedRole,
CreatedEmail = annotation.CreatedEmail,
CreatedDate = annotation.CreatedDate,
Status = annotation.AnnotationStatus,
ImageExtension = annotation.ImageExtension,
Image = image,
Detections = JsonConvert.SerializeObject(annotation.Detections),
Source = annotation.Source
Source = annotation.Source,
};
messages.Add(annCreateMessage);
}