Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging who runs a robot mission (action log in flotilla) #1712

Merged
merged 9 commits into from
Aug 13, 2024
Merged
4 changes: 3 additions & 1 deletion backend/api.test/Database/DatabaseUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class DatabaseUtilities
private readonly PlantService _plantService;
private readonly RobotModelService _robotModelService;
private readonly RobotService _robotService;
private readonly UserInfoService _userInfoService;

public DatabaseUtilities(FlotillaDbContext context)
{
Expand All @@ -30,7 +31,8 @@ public DatabaseUtilities(FlotillaDbContext context)
_plantService = new PlantService(context, _installationService, _accessRoleService);
_deckService = new DeckService(context, defaultLocalizationPoseService, _installationService, _plantService, _accessRoleService, new MockSignalRService());
_areaService = new AreaService(context, _installationService, _plantService, _deckService, defaultLocalizationPoseService, _accessRoleService);
_missionRunService = new MissionRunService(context, new MockSignalRService(), new Mock<ILogger<MissionRunService>>().Object, _accessRoleService);
_userInfoService = new UserInfoService(context, new HttpContextAccessor(), new Mock<ILogger<UserInfoService>>().Object);
_missionRunService = new MissionRunService(context, new MockSignalRService(), new Mock<ILogger<MissionRunService>>().Object, _accessRoleService, _userInfoService);
_robotModelService = new RobotModelService(context);
_robotService = new RobotService(context, new Mock<ILogger<RobotService>>().Object, _robotModelService, new MockSignalRService(), _accessRoleService, _installationService, _areaService, _missionRunService);
}
Expand Down
4 changes: 3 additions & 1 deletion backend/api.test/EventHandlers/TestMissionEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ public TestMissionEventHandler(DatabaseFixture fixture)

var signalRService = new MockSignalRService();
var accessRoleService = new AccessRoleService(context, new HttpContextAccessor());
var userInfoService = new UserInfoService(context, new HttpContextAccessor(), new Mock<ILogger<UserInfoService>>().Object);

_mqttService = new MqttService(mqttServiceLogger, configuration);
_missionRunService = new MissionRunService(context, signalRService, missionLogger, accessRoleService);

_missionRunService = new MissionRunService(context, signalRService, missionLogger, accessRoleService, userInfoService);


var echoServiceMock = new MockEchoService();
Expand Down
4 changes: 3 additions & 1 deletion backend/api.test/Services/MissionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ public class MissionServiceTest : IDisposable
private readonly MissionRunService _missionRunService;
private readonly ISignalRService _signalRService;
private readonly IAccessRoleService _accessRoleService;
private readonly UserInfoService _userInfoService;

public MissionServiceTest(DatabaseFixture fixture)
{
_context = fixture.NewContext;
_logger = new Mock<ILogger<MissionRunService>>().Object;
_signalRService = new MockSignalRService();
_accessRoleService = new AccessRoleService(_context, new HttpContextAccessor());
_missionRunService = new MissionRunService(_context, _signalRService, _logger, _accessRoleService);
_userInfoService = new UserInfoService(_context, new HttpContextAccessor(), new Mock<ILogger<UserInfoService>>().Object);
_missionRunService = new MissionRunService(_context, _signalRService, _logger, _accessRoleService, _userInfoService);
_databaseUtilities = new DatabaseUtilities(_context);
}

Expand Down
4 changes: 3 additions & 1 deletion backend/api.test/Services/RobotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class RobotServiceTest : IDisposable
private readonly IDeckService _deckService;
private readonly IAreaService _areaService;
private readonly IMissionRunService _missionRunService;
private readonly IUserInfoService _userInfoService;

public RobotServiceTest(DatabaseFixture fixture)
{
Expand All @@ -39,7 +40,8 @@ public RobotServiceTest(DatabaseFixture fixture)
_defaultLocalizationPoseService = new DefaultLocalizationPoseService(_context);
_deckService = new DeckService(_context, _defaultLocalizationPoseService, _installationService, _plantService, _accessRoleService, _signalRService);
_areaService = new AreaService(_context, _installationService, _plantService, _deckService, _defaultLocalizationPoseService, _accessRoleService);
_missionRunService = new MissionRunService(_context, _signalRService, new Mock<ILogger<MissionRunService>>().Object, _accessRoleService);
_userInfoService = new UserInfoService(_context, new HttpContextAccessor(), new Mock<ILogger<UserInfoService>>().Object);
_missionRunService = new MissionRunService(_context, _signalRService, new Mock<ILogger<MissionRunService>>().Object, _accessRoleService, _userInfoService);
}

public void Dispose()
Expand Down
1 change: 1 addition & 0 deletions backend/api/Database/Context/FlotillaDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class FlotillaDbContext(DbContextOptions options) : DbContext(options)
public DbSet<SafePosition> SafePositions => Set<SafePosition>();
public DbSet<DefaultLocalizationPose> DefaultLocalizationPoses => Set<DefaultLocalizationPose>();
public DbSet<AccessRole> AccessRoles => Set<AccessRole>();
public DbSet<UserInfo> UserInfos => Set<UserInfo>();

// Timeseries:
public DbSet<RobotPressureTimeseries> RobotPressureTimeseries => Set<RobotPressureTimeseries>();
Expand Down
15 changes: 15 additions & 0 deletions backend/api/Database/Models/UserInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

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