Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
491 changes: 491 additions & 0 deletions api/src/Feature.Statistics/GetElectionRoundStatistics/Endpoint.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Feature.Statistics.GetElectionRoundStatistics;

public class NgosStats
{
public int ActiveNgos { get; set; }
public int InactiveNgos { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Feature.Statistics.GetElectionRoundStatistics;

public class Request
{
public Guid ElectionRoundId { get; set; }
}
22 changes: 22 additions & 0 deletions api/src/Feature.Statistics/GetElectionRoundStatistics/Response.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Feature.Statistics.GetNgoAdminStatistics.Models;

namespace Feature.Statistics.GetElectionRoundStatistics;

public class Response
{
public NgosStats NgosStats { get; set; } = new();
public ObserversStats ObserversStats { get; set; } = new();

public VisitedPollingStationLevelStats? TotalStats { get; set; }
public List<VisitedPollingStationLevelStats> Level1Stats { get; set; } = [];
public List<VisitedPollingStationLevelStats> Level2Stats { get; set; } = [];
public List<VisitedPollingStationLevelStats> Level3Stats { get; set; } = [];
public List<VisitedPollingStationLevelStats> Level4Stats { get; set; } = [];
public List<VisitedPollingStationLevelStats> Level5Stats { get; set; } = [];
public HistogramPoint[] FormsHistogram { get; set; } = [];
public HistogramPoint[] QuestionsHistogram { get; set; } = [];
public HistogramPoint[] FlaggedAnswersHistogram { get; set; } = [];
public HistogramPoint[] QuickReportsHistogram { get; set; } = [];
public HistogramPoint[] IncidentReportsHistogram { get; set; } = [];
public HistogramPoint[] CitizenReportsHistogram { get; set; } = [];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Feature.Statistics.GetElectionRoundStatistics;

public class Validator : Validator<Request>
{
public Validator()
{
RuleFor(x => x.ElectionRoundId).NotEmpty();
}
}
510 changes: 510 additions & 0 deletions api/src/Feature.Statistics/GetMonitoringNgoStatistics/Endpoint.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Feature.Statistics.GetMonitoringNgoStatistics;

public class Request
{
public Guid ElectionRoundId { get; set; }
public Guid MonitoringNgoId { get; set; }
}
22 changes: 22 additions & 0 deletions api/src/Feature.Statistics/GetMonitoringNgoStatistics/Response.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Feature.Statistics.GetNgoAdminStatistics.Models;

namespace Feature.Statistics.GetMonitoringNgoStatistics;

public class Response
{
public string Status { get; set; } = string.Empty;
public ObserversStats ObserversStats { get; set; } = new();

public VisitedPollingStationLevelStats? TotalStats { get; set; }
public List<VisitedPollingStationLevelStats> Level1Stats { get; set; } = [];
public List<VisitedPollingStationLevelStats> Level2Stats { get; set; } = [];
public List<VisitedPollingStationLevelStats> Level3Stats { get; set; } = [];
public List<VisitedPollingStationLevelStats> Level4Stats { get; set; } = [];
public List<VisitedPollingStationLevelStats> Level5Stats { get; set; } = [];
public HistogramPoint[] FormsHistogram { get; set; } = [];
public HistogramPoint[] QuestionsHistogram { get; set; } = [];
public HistogramPoint[] FlaggedAnswersHistogram { get; set; } = [];
public HistogramPoint[] QuickReportsHistogram { get; set; } = [];
public HistogramPoint[] IncidentReportsHistogram { get; set; } = [];
public HistogramPoint[] CitizenReportsHistogram { get; set; } = [];
}
10 changes: 10 additions & 0 deletions api/src/Feature.Statistics/GetMonitoringNgoStatistics/Validator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Feature.Statistics.GetMonitoringNgoStatistics;

public class Validator : Validator<Request>
{
public Validator()
{
RuleFor(x => x.ElectionRoundId).NotEmpty();
RuleFor(x => x.MonitoringNgoId).NotEmpty();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Feature.Statistics.GetElectionRoundStatistics;

namespace Feature.Statistics.UnitTests.Validators;

public class GetElectionRoundStatisticsValidatorTests
{
private readonly Validator _validator = new();

[Fact]
public void Validation_ShouldPass_When_ElectionRoundId_NotEmpty()
{
// Arrange
var request = new Request { ElectionRoundId = Guid.NewGuid() };

// Act
var result = _validator.TestValidate(request);

// Assert
result.ShouldNotHaveValidationErrorFor(x => x.ElectionRoundId);
}

[Fact]
public void Validation_ShouldFail_When_ElectionRoundId_Empty()
{
// Arrange
var request = new Request { ElectionRoundId = Guid.Empty };

// Act
var result = _validator.TestValidate(request);

// Assert
result.ShouldHaveValidationErrorFor(x => x.ElectionRoundId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Feature.Statistics.GetMonitoringNgoStatistics;

namespace Feature.Statistics.UnitTests.Validators;

public class GetMonitoringNgoStatisticsValidatorTests
{
private readonly Validator _validator = new();

[Fact]
public void Validation_ShouldPass_When_Request_Valid()
{
// Arrange
var request = new Request
{
ElectionRoundId = Guid.NewGuid(),
MonitoringNgoId = Guid.NewGuid()
};

// Act
var result = _validator.TestValidate(request);

// Assert
result.ShouldNotHaveAnyValidationErrors();
}

[Fact]
public void Validation_ShouldFail_When_ElectionRoundId_Empty()
{
// Arrange
var request = new Request
{
ElectionRoundId = Guid.Empty,
MonitoringNgoId = Guid.NewGuid()
};

// Act
var result = _validator.TestValidate(request);

// Assert
result.ShouldHaveValidationErrorFor(x => x.ElectionRoundId);
}

[Fact]
public void Validation_ShouldFail_When_MonitoringNgoId_Empty()
{
// Arrange
var request = new Request
{
ElectionRoundId = Guid.NewGuid(),
MonitoringNgoId = Guid.Empty
};

// Act
var result = _validator.TestValidate(request);

// Assert
result.ShouldHaveValidationErrorFor(x => x.MonitoringNgoId);
}
}
Loading