Skip to content

Commit

Permalink
Adds InspectionFindings Table
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadUsama-afk-equinor committed Nov 6, 2023
1 parent a400adc commit 3747e4d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/api/Database/Context/FlotillaDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class FlotillaDbContext : DbContext
public DbSet<Installation> Installations => Set<Installation>();
public DbSet<Deck> Decks => Set<Deck>();
public DbSet<Area> Areas => Set<Area>();

public DbSet<Source> Sources => Set<Source>();
public DbSet<SafePosition> SafePositions => Set<SafePosition>();
public DbSet<DefaultLocalizationPose> DefaultLocalizationPoses => Set<DefaultLocalizationPose>();
Expand Down Expand Up @@ -49,7 +50,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
if (isSqlLite)
AddConverterForDateTimeOffsets(ref inspectionEntity);

inspectionEntity.OwnsMany(i => i.InspectionFindings);

}

);
taskEntity.OwnsOne(task => task.InspectionTarget);
taskEntity.OwnsOne(
Expand Down
37 changes: 37 additions & 0 deletions backend/api/Database/Models/Inspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,43 @@ public class Inspection

private InspectionStatus _status;

[Required]
public InspectionStatus Status
{
get { return _status; }
set
{
_status = value;
if (IsCompleted && EndTime is null)
EndTime = DateTimeOffset.UtcNow;

if (_status is InspectionStatus.InProgress && StartTime is null)
StartTime = DateTimeOffset.UtcNow;
}
}

public bool IsCompleted =>
_status
is InspectionStatus.Cancelled
or InspectionStatus.Successful
or InspectionStatus.Failed;

[Required]
public InspectionType InspectionType { get; set; }

public float? VideoDuration { get; set; }

public AnalysisType? AnalysisType { get; set; }

[MaxLength(250)]
public string? InspectionUrl { get; set; }

public DateTimeOffset? StartTime { get; private set; }

public DateTimeOffset? EndTime { get; private set; }

public List<InspectionFindings> InspectionFindings { get; set; }

public Inspection()
{
InspectionType = InspectionType.Image;
Expand Down
29 changes: 29 additions & 0 deletions backend/api/Database/Models/InspectionFindings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Api.Controllers.Models;
using Api.Services.Models;
using Microsoft.EntityFrameworkCore;

#pragma warning disable CS8618
namespace Api.Database.Models
{
[Owned]
public class InspectionFindings
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }

public string RobotName { get; set; }

public string InspectionDate { get; set; }

public string Area { get; set; }

public string InspectionId { get; set; }

public string FindingsTag { get; set; }

}

}

0 comments on commit 3747e4d

Please sign in to comment.