fixed sorting in datasetexplorer, also show date

make annotationstatus more clear
This commit is contained in:
Alex Bezdieniezhnykh
2025-05-20 11:02:24 +03:00
parent 66bfe474c2
commit a5fcb0988b
6 changed files with 30 additions and 24 deletions
+5 -1
View File
@@ -4,6 +4,7 @@ using System.Runtime.CompilerServices;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Azaion.Common.Database; using Azaion.Common.Database;
using Azaion.Common.Extensions; using Azaion.Common.Extensions;
using Azaion.CommonSecurity.DTO;
namespace Azaion.Common.DTO; namespace Azaion.Common.DTO;
@@ -29,8 +30,11 @@ public class AnnotationThumbnail(Annotation annotation, bool isValidator) : INot
} }
public string ImageName => Path.GetFileName(Annotation.ImagePath); public string ImageName => Path.GetFileName(Annotation.ImagePath);
public string CreatedDate => $"{Annotation.CreatedDate:dd.MM.yyyy HH:mm:ss}";
public string CreatedEmail => Annotation.CreatedEmail; public string CreatedEmail => Annotation.CreatedEmail;
public bool IsSeed => IsValidator && Annotation.AnnotationStatus == AnnotationStatus.Created; public bool IsSeed => IsValidator &&
Annotation.AnnotationStatus.In(AnnotationStatus.Created, AnnotationStatus.Edited) &&
!Annotation.CreatedRole.IsValidator();
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
+1 -2
View File
@@ -59,8 +59,7 @@ public enum AnnotationStatus
{ {
None = 0, None = 0,
Created = 10, Created = 10,
ValidatedEdited = 20, Edited = 20,
Validated = 30, Validated = 30,
Deleted = 40 Deleted = 40
} }
+4 -11
View File
@@ -88,7 +88,7 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
if (email != _api.CurrentUser.Email) //Don't process messages by yourself if (email != _api.CurrentUser.Email) //Don't process messages by yourself
{ {
if (annotationStatus.In(AnnotationStatus.Created, AnnotationStatus.ValidatedEdited)) if (annotationStatus.In(AnnotationStatus.Created, AnnotationStatus.Edited))
{ {
var msg = MessagePackSerializer.Deserialize<AnnotationMessage>(message.Data.Contents); var msg = MessagePackSerializer.Deserialize<AnnotationMessage>(message.Data.Contents);
await SaveAnnotationInner( await SaveAnnotationInner(
@@ -161,25 +161,18 @@ public class AnnotationService : IAnnotationService, INotificationHandler<Annota
if (ann != null) //Annotation is already exists if (ann != null) //Annotation is already exists
{ {
status = AnnotationStatus.Edited;
var annotationUpdatable = db.Annotations var annotationUpdatable = db.Annotations
.Where(x => x.Name == fName) .Where(x => x.Name == fName)
.Set(x => x.Source, source) .Set(x => x.Source, source);
.Set(x => x.CreatedRole, userRole);
if (userRole.IsValidator() && source == SourceEnum.Manual) if (userRole.IsValidator() && source == SourceEnum.Manual)
{ {
status = AnnotationStatus.ValidatedEdited;
annotationUpdatable = annotationUpdatable annotationUpdatable = annotationUpdatable
.Set(x => x.ValidateDate, createdDate) .Set(x => x.ValidateDate, createdDate)
.Set(x => x.ValidateEmail, createdEmail); .Set(x => x.ValidateEmail, createdEmail);
} }
else
{
annotationUpdatable = annotationUpdatable
.Set(x => x.CreatedDate, createdDate)
.Set(x => x.CreatedEmail, createdEmail);
}
await annotationUpdatable await annotationUpdatable
.Set(x => x.AnnotationStatus, status) .Set(x => x.AnnotationStatus, status)
+1 -1
View File
@@ -66,7 +66,7 @@ public class FailsafeAnnotationsProducer
{ {
var records = await db.AnnotationsQueueRecords.OrderBy(x => x.DateTime).ToListAsync(token: ct); var records = await db.AnnotationsQueueRecords.OrderBy(x => x.DateTime).ToListAsync(token: ct);
var editedCreatedNames = records var editedCreatedNames = records
.Where(x => x.Operation.In(AnnotationStatus.Created, AnnotationStatus.ValidatedEdited)) .Where(x => x.Operation.In(AnnotationStatus.Created, AnnotationStatus.Edited))
.Select(x => x.AnnotationNames.FirstOrDefault()) .Select(x => x.AnnotationNames.FirstOrDefault())
.ToList(); .ToList();
+8 -2
View File
@@ -46,8 +46,14 @@
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="2"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Foreground="Gray" Foreground="Gray">
Text="{Binding CreatedEmail}" /> <TextBlock.Text>
<MultiBinding StringFormat="{}{0}: {1}">
<Binding Mode="OneWay" Path="CreatedDate"></Binding>
<Binding Mode="OneWay" Path="CreatedEmail"></Binding>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid> </Grid>
</Border> </Border>
</DataTemplate> </DataTemplate>
+11 -7
View File
@@ -288,14 +288,18 @@ public partial class DatasetExplorer
{ {
SelectedAnnotations.Clear(); SelectedAnnotations.Clear();
SelectedAnnotationDict.Clear(); SelectedAnnotationDict.Clear();
var annotations = _annotationsDict[ExplorerEditor.CurrentAnnClass.YoloId]; var annThumbnails = _annotationsDict[ExplorerEditor.CurrentAnnClass.YoloId]
foreach (var ann in annotations .Select(x => new AnnotationThumbnail(x.Value, _azaionApi.CurrentUser.Role.IsValidator()))
.OrderBy(x => x.Value.AnnotationStatus) .OrderBy(x => !x.IsSeed)
.ThenByDescending(x => x.Value.CreatedDate)) .ThenByDescending(x =>x.Annotation.CreatedDate);
//var dict = annThumbnails.Take(20).ToDictionary(x => x.Annotation.Name, x => x.IsSeed);
foreach (var thumb in annThumbnails)
{ {
var annThumb = new AnnotationThumbnail(ann.Value, _azaionApi.CurrentUser.Role.IsValidator()); SelectedAnnotations.Add(thumb);
SelectedAnnotations.Add(annThumb); SelectedAnnotationDict.Add(thumb.Annotation.Name, thumb);
SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
} }
await Task.CompletedTask; await Task.CompletedTask;
} }