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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private async Task<Results<Ok<Response>, NotFound>> AggregateCitizenReportsAsync
EF.Functions.ILike(x.Location.Level4, req.Level4Filter))
.Where(x => string.IsNullOrWhiteSpace(req.Level5Filter) ||
EF.Functions.ILike(x.Location.Level5, req.Level5Filter))
.Where(x => req.LocationId == null || x.LocationId == req.LocationId)
.Where(x => req.HasFlaggedAnswers == null || (req.HasFlaggedAnswers.Value
? x.NumberOfFlaggedAnswers > 0
: x.NumberOfFlaggedAnswers == 0))
Expand Down Expand Up @@ -133,6 +134,7 @@ private async Task<Results<Ok<Response>, NotFound>> AggregateCitizenReportsAsync
Level3Filter = req.Level3Filter,
Level4Filter = req.Level4Filter,
Level5Filter = req.Level5Filter,
LocationId = req.LocationId,
HasFlaggedAnswers = req.HasFlaggedAnswers,
QuestionsAnswered = req.QuestionsAnswered,
FollowUpStatus = req.FollowUpStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class SubmissionsFilterModel

public string? Level5Filter { get; set; }

public Guid? LocationId { get; set; }

public bool? HasFlaggedAnswers { get; set; }

public CitizenReportFollowUpStatus? FollowUpStatus { get; set; }
Expand Down
5 changes: 4 additions & 1 deletion api/src/Feature.CitizenReports/ListEntries/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ @followUpStatus IS NULL
AND (@level2 IS NULL OR L."Level2" = @level2)
AND (@level3 IS NULL OR L."Level3" = @level3)
AND (@level4 IS NULL OR L."Level4" = @level4)
AND (@level5 IS NULL OR L."Level5" = @level5)
AND (@level5 IS NULL OR L."Level5" = @level5)
AND (@locationId IS NULL OR CR."LocationId" = @locationId)
AND (@formId IS NULL OR CR."FormId" = @formId)
AND (@questionsAnswered IS NULL
OR (@questionsAnswered = 'All' AND F."NumberOfQuestions" = CR."NumberOfQuestionsAnswered")
Expand Down Expand Up @@ -125,6 +126,7 @@ @followUpStatus IS NULL
AND (@level3 IS NULL OR L."Level3" = @level3)
AND (@level4 IS NULL OR L."Level4" = @level4)
AND (@level5 IS NULL OR L."Level5" = @level5)
AND (@locationId IS NULL OR CR."LocationId" = @locationId)
AND (@hasFlaggedAnswers is NULL OR @hasFlaggedAnswers = false OR 1 = 2)
AND (@formId IS NULL OR CR."FormId" = @formId)
AND (@questionsAnswered IS NULL
Expand Down Expand Up @@ -225,6 +227,7 @@ OFFSET @offset ROWS
level3 = req.Level3Filter,
level4 = req.Level4Filter,
level5 = req.Level5Filter,
locationId = req.LocationId,
formId = req.FormId,
hasAttachments = req.HasAttachments,
hasNotes = req.HasNotes,
Expand Down
1 change: 1 addition & 0 deletions api/src/Feature.CitizenReports/ListEntries/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Request : BaseSortPaginatedRequest
[QueryParam] public string? Level3Filter { get; set; }
[QueryParam] public string? Level4Filter { get; set; }
[QueryParam] public string? Level5Filter { get; set; }
[QueryParam] public Guid? LocationId { get; set; }
[QueryParam] public bool? HasFlaggedAnswers { get; set; }
[QueryParam] public CitizenReportFollowUpStatus? FollowUpStatus { get; set; }
[QueryParam] public Guid? FormId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class CitizenReportsAggregateFilter

[QueryParam] public string? Level5Filter { get; set; }

[QueryParam] public Guid? LocationId { get; set; }

[QueryParam] public bool? HasFlaggedAnswers { get; set; }

[QueryParam] public CitizenReportFollowUpStatus? FollowUpStatus { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions api/src/Feature.DataExport/Start/CitizenReportsFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public record CitizenReportsFilters
public string? Level3Filter { get; init; }
public string? Level4Filter { get; init; }
public string? Level5Filter { get; init; }
public Guid? LocationId { get; init; }
public bool? HasFlaggedAnswers { get; init; }
public CitizenReportFollowUpStatus? FollowUpStatus { get; init; }
public Guid? FormId { get; init; }
Expand All @@ -34,6 +35,7 @@ public ExportCitizenReportsFilers ToFilter()
Level3Filter = Level3Filter,
Level4Filter = Level4Filter,
Level5Filter = Level5Filter,
LocationId = LocationId,
HasFlaggedAnswers = HasFlaggedAnswers,
FollowUpStatus = FollowUpStatus,
FormId = FormId,
Expand Down
3 changes: 3 additions & 0 deletions api/src/Feature.DataExport/Start/FormSubmissionsFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public record FormSubmissionsFilters

public string? PollingStationNumberFilter { get; init; }

public Guid? PollingStationId { get; init; }

public bool? HasFlaggedAnswers { get; init; }

public SubmissionFollowUpStatus? FollowUpStatus { get; init; }
Expand Down Expand Up @@ -57,6 +59,7 @@ public ExportFormSubmissionsFilters ToFilter()
Level4Filter = Level4Filter,
Level5Filter = Level5Filter,
PollingStationNumberFilter = PollingStationNumberFilter,
PollingStationId = PollingStationId,
HasFlaggedAnswers = HasFlaggedAnswers,
FollowUpStatus = FollowUpStatus,
MonitoringObserverId = MonitoringObserverId,
Expand Down
3 changes: 3 additions & 0 deletions api/src/Feature.DataExport/Start/IncidentReportsFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public record IncidentReportsFilters

public string? PollingStationNumberFilter { get; init; }

public Guid? PollingStationId { get; init; }

public bool? HasFlaggedAnswers { get; init; }

public Guid? MonitoringObserverId { get; init; }
Expand Down Expand Up @@ -54,6 +56,7 @@ public ExportIncidentReportsFilters ToFilter()
Level4Filter = Level4Filter,
Level5Filter = Level5Filter,
PollingStationNumberFilter = PollingStationNumberFilter,
PollingStationId = PollingStationId,
HasFlaggedAnswers = HasFlaggedAnswers,
MonitoringObserverId = MonitoringObserverId,
TagsFilter = TagsFilter,
Expand Down
2 changes: 2 additions & 0 deletions api/src/Feature.DataExport/Start/QuickReportsFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public record QuickReportsFilters
public DateTime? ToDateFilter { get; init; }
public bool? HasAttachments { get; init; }
public Guid? MonitoringObserverId { get; init; }
public Guid? PollingStationId { get; init; }
public string[]? TagsFilter { get; init; } = [];

public ExportQuickReportsFilters ToFilter()
Expand All @@ -43,6 +44,7 @@ public ExportQuickReportsFilters ToFilter()
CoalitionMemberId = CoalitionMemberId,
HasAttachments = HasAttachments,
MonitoringObserverId = MonitoringObserverId,
PollingStationId = PollingStationId,
TagsFilter = TagsFilter
};
}
Expand Down
7 changes: 7 additions & 0 deletions api/src/Feature.Form.Submissions/GetAggregated/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ @LEVEL5 IS NULL
@POLLINGSTATIONNUMBER IS NULL
OR PS."Number" = @POLLINGSTATIONNUMBER
)
AND (
@POLLINGSTATIONID IS NULL
OR PS."Id" = @POLLINGSTATIONID
)
AND (
@HASFLAGGEDANSWERS IS NULL
OR (
Expand Down Expand Up @@ -400,6 +404,7 @@ @HASATTACHMENTS IS NULL
level4 = req.Level4Filter,
level5 = req.Level5Filter,
pollingStationNumber = req.PollingStationNumberFilter,
pollingStationId = req.PollingStationId,
hasFlaggedAnswers = req.HasFlaggedAnswers,
followUpStatus = req.FollowUpStatus?.ToString(),
tagsFilter = req.TagsFilter ?? [],
Expand Down Expand Up @@ -474,6 +479,7 @@ @HASATTACHMENTS IS NULL
HasFlaggedAnswers = req.HasFlaggedAnswers,
MonitoringObserverStatus = req.MonitoringObserverStatus,
PollingStationNumberFilter = req.PollingStationNumberFilter,
PollingStationId = req.PollingStationId,
DataSource = req.DataSource!,
CoalitionMemberId = req.CoalitionMemberId,
}
Expand Down Expand Up @@ -506,6 +512,7 @@ private async Task<Results<Ok<Response>, NotFound>> AggregatePSIFormSubmissionsA
EF.Functions.ILike(x.PollingStation.Level5, req.Level5Filter))
.Where(x => string.IsNullOrWhiteSpace(req.PollingStationNumberFilter) ||
EF.Functions.ILike(x.PollingStation.Number, req.PollingStationNumberFilter))
.Where(x => req.PollingStationId == null || x.PollingStationId == req.PollingStationId)
.Where(x => req.HasFlaggedAnswers == null || (req.HasFlaggedAnswers.Value
? x.NumberOfFlaggedAnswers > 0
: x.NumberOfFlaggedAnswers == 0))
Expand Down
2 changes: 2 additions & 0 deletions api/src/Feature.Form.Submissions/GetAggregated/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class SubmissionsFilterModel

public string? PollingStationNumberFilter { get; set; }

public Guid? PollingStationId { get; set; }

public bool? HasFlaggedAnswers { get; set; }

public SubmissionFollowUpStatus? FollowUpStatus { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions api/src/Feature.Form.Submissions/ListEntries/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ OR mo."PhoneNumber" ILIKE @searchText
AND (@level4 IS NULL OR ps."Level4" = @level4)
AND (@level5 IS NULL OR ps."Level5" = @level5)
AND (@pollingStationNumber IS NULL OR ps."Number" = @pollingStationNumber)
AND (@pollingStationId IS NULL OR ps."Id" = @pollingStationId)
AND (@hasFlaggedAnswers is NULL OR @hasFlaggedAnswers = false OR 1 = 2)
AND (@followUpStatus is NULL OR psi."FollowUpStatus" = @followUpStatus)
AND (@monitoringObserverStatus IS NULL OR mo."Status" = @monitoringObserverStatus)
Expand Down Expand Up @@ -83,6 +84,7 @@ OR mo."PhoneNumber" ILIKE @searchText
AND (@level4 IS NULL OR ps."Level4" = @level4)
AND (@level5 IS NULL OR ps."Level5" = @level5)
AND (@pollingStationNumber IS NULL OR ps."Number" = @pollingStationNumber)
AND (@pollingStationId IS NULL OR ps."Id" = @pollingStationId)
AND (@hasFlaggedAnswers is NULL OR (fs."NumberOfFlaggedAnswers" = 0 AND @hasFlaggedAnswers = false) OR
("NumberOfFlaggedAnswers" > 0 AND @hasFlaggedAnswers = true))
AND (@followUpStatus is NULL OR fs."FollowUpStatus" = @followUpStatus)
Expand Down Expand Up @@ -271,6 +273,7 @@ UNION ALL
AND (@level4 IS NULL OR ps."Level4" = @level4)
AND (@level5 IS NULL OR ps."Level5" = @level5)
AND (@pollingStationNumber IS NULL OR ps."Number" = @pollingStationNumber)
AND (@pollingStationId IS NULL OR ps."Id" = @pollingStationId)
AND (@hasFlaggedAnswers IS NULL
OR (s."NumberOfFlaggedAnswers" = 0 AND @hasFlaggedAnswers = false)
OR (s."NumberOfFlaggedAnswers" > 0 AND @hasFlaggedAnswers = true))
Expand Down Expand Up @@ -331,6 +334,7 @@ UNION ALL
level4 = req.Level4Filter,
level5 = req.Level5Filter,
pollingStationNumber = req.PollingStationNumberFilter,
pollingStationId = req.PollingStationId,
hasFlaggedAnswers = req.HasFlaggedAnswers,
followUpStatus = req.FollowUpStatus?.ToString(),
tagsFilter = req.TagsFilter ?? [],
Expand Down
2 changes: 2 additions & 0 deletions api/src/Feature.Form.Submissions/ListEntries/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Request : BaseSortPaginatedRequest

[QueryParam] public string? PollingStationNumberFilter { get; set; }

[QueryParam] public Guid? PollingStationId { get; set; }

[QueryParam] public bool? HasFlaggedAnswers { get; set; }

[QueryParam] public SubmissionFollowUpStatus? FollowUpStatus { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ OR mo."PhoneNumber" ILIKE @searchText
AND (@level4 IS NULL OR ps."Level4" = @level4)
AND (@level5 IS NULL OR ps."Level5" = @level5)
AND (@pollingStationNumber IS NULL OR ps."Number" = @pollingStationNumber)
AND (@pollingStationId IS NULL OR ps."Id" = @pollingStationId)
AND (@hasFlaggedAnswers is NULL OR @hasFlaggedAnswers = false OR 1 = 2)
AND (@followUpStatus is NULL OR psi."FollowUpStatus" = @followUpStatus)
AND (@monitoringObserverStatus IS NULL OR mo."Status" = @monitoringObserverStatus)
Expand Down Expand Up @@ -87,6 +88,7 @@ OR mo."PhoneNumber" ILIKE @searchText
AND (@level4 IS NULL OR ps."Level4" = @level4)
AND (@level5 IS NULL OR ps."Level5" = @level5)
AND (@pollingStationNumber IS NULL OR ps."Number" = @pollingStationNumber)
AND (@pollingStationId IS NULL OR ps."Id" = @pollingStationId)
AND (@hasFlaggedAnswers is NULL OR (fs."NumberOfFlaggedAnswers" = 0 AND @hasFlaggedAnswers = false) OR
("NumberOfFlaggedAnswers" > 0 AND @hasFlaggedAnswers = true))
AND (@followUpStatus is NULL OR fs."FollowUpStatus" = @followUpStatus)
Expand Down Expand Up @@ -307,6 +309,7 @@ UNION ALL
AND (@level4 IS NULL OR ps."Level4" = @level4)
AND (@level5 IS NULL OR ps."Level5" = @level5)
AND (@pollingStationNumber IS NULL OR ps."Number" = @pollingStationNumber)
AND (@pollingStationId IS NULL OR ps."Id" = @pollingStationId)
AND (@hasFlaggedAnswers IS NULL
OR (s."NumberOfFlaggedAnswers" = 0 AND @hasFlaggedAnswers = false)
OR (s."NumberOfFlaggedAnswers" > 0 AND @hasFlaggedAnswers = true))
Expand Down Expand Up @@ -369,6 +372,7 @@ UNION ALL
level4 = req.Level4Filter,
level5 = req.Level5Filter,
pollingStationNumber = req.PollingStationNumberFilter,
pollingStationId = req.PollingStationId,
hasFlaggedAnswers = req.HasFlaggedAnswers,
followUpStatus = req.FollowUpStatus?.ToString(),
tagsFilter = req.TagsFilter ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Request : BaseSortPaginatedRequest

[QueryParam] public string? PollingStationNumberFilter { get; set; }

[QueryParam] public Guid? PollingStationId { get; set; }

[QueryParam] public bool? HasFlaggedAnswers { get; set; }

[QueryParam] public SubmissionFollowUpStatus? FollowUpStatus { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class FormSubmissionsAggregateFilter

[QueryParam] public string? PollingStationNumberFilter { get; set; }

[QueryParam] public Guid? PollingStationId { get; set; }

[QueryParam] public bool? HasFlaggedAnswers { get; set; }

[QueryParam] public SubmissionFollowUpStatus? FollowUpStatus { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private async Task<Results<Ok<Response>, NotFound>> AggregateIncidentReportsAsyn
.Where(x => x.PollingStation != null
&& (string.IsNullOrWhiteSpace(req.PollingStationNumberFilter)
|| EF.Functions.ILike(x.PollingStation.Number, req.PollingStationNumberFilter)))
.Where(x => req.PollingStationId == null || x.PollingStationId == req.PollingStationId)
.Where(x => req.HasFlaggedAnswers == null || (req.HasFlaggedAnswers.Value
? x.NumberOfFlaggedAnswers > 0
: x.NumberOfFlaggedAnswers == 0))
Expand Down Expand Up @@ -147,7 +148,8 @@ private async Task<Results<Ok<Response>, NotFound>> AggregateIncidentReportsAsyn
IsCompletedFilter = req.IsCompletedFilter,
LocationTypeFilter = req.LocationTypeFilter,
FollowUpStatusFilter = req.FollowUpStatusFilter,
PollingStationNumberFilter = req.PollingStationNumberFilter
PollingStationNumberFilter = req.PollingStationNumberFilter,
PollingStationId = req.PollingStationId
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class SubmissionsFilterModel

public string? Level5Filter { get; set; }
public string? PollingStationNumberFilter { get; set; }
public Guid? PollingStationId { get; set; }

public bool? HasFlaggedAnswers { get; set; }

Expand Down
3 changes: 3 additions & 0 deletions api/src/Feature.IncidentReports/ListEntries/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ OR U."PhoneNumber" ILIKE @searchText
AND (@level4 IS NULL OR PS."Level4" = @level4)
AND (@level5 IS NULL OR PS."Level5" = @level5)
AND (@pollingStationNumber IS NULL OR PS."Number" = @pollingStationNumber)
AND (@pollingStationId IS NULL OR IR."PollingStationId" = @pollingStationId)
AND (@hasFlaggedAnswers IS NULL
OR (IR."NumberOfFlaggedAnswers" = 0 AND @hasFlaggedAnswers = FALSE)
OR ("NumberOfFlaggedAnswers" > 0 AND @hasFlaggedAnswers = TRUE)
Expand Down Expand Up @@ -202,6 +203,7 @@ OR U."PhoneNumber" ILIKE @searchText
AND (@level4 IS NULL OR PS."Level4" = @level4)
AND (@level5 IS NULL OR PS."Level5" = @level5)
AND (@pollingStationNumber IS NULL OR PS."Number" = @pollingStationNumber)
AND (@pollingStationId IS NULL OR IR."PollingStationId" = @pollingStationId)
AND (@hasFlaggedAnswers IS NULL
OR (IR."NumberOfFlaggedAnswers" = 0 AND @hasFlaggedAnswers = FALSE)
OR (IR."NumberOfFlaggedAnswers" > 0 AND @hasFlaggedAnswers = TRUE)
Expand Down Expand Up @@ -262,6 +264,7 @@ OFFSET @offset ROWS
level4 = req.Level4Filter,
level5 = req.Level5Filter,
pollingStationNumber = req.PollingStationNumberFilter,
pollingStationId = req.PollingStationId,
hasFlaggedAnswers = req.HasFlaggedAnswers,
followUpStatus = req.FollowUpStatus?.ToString(),
tagsFilter = req.TagsFilter ?? [],
Expand Down
2 changes: 2 additions & 0 deletions api/src/Feature.IncidentReports/ListEntries/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class Request : BaseSortPaginatedRequest

[QueryParam] public string? PollingStationNumberFilter { get; set; }

[QueryParam] public Guid? PollingStationId { get; set; }

[QueryParam] public bool? HasFlaggedAnswers { get; set; }

[QueryParam] public Guid? MonitoringObserverId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class IncidentReportsAggregateFilter
[QueryParam] public string? Level5Filter { get; set; }
[QueryParam] public string? PollingStationNumberFilter { get; set; }

[QueryParam] public Guid? PollingStationId { get; set; }

[QueryParam] public bool? HasFlaggedAnswers { get; set; }

[QueryParam] public IncidentReportFollowUpStatus? FollowUpStatusFilter { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions api/src/Feature.QuickReports/List/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ @level4 IS NULL
@level5 IS NULL
OR PS."Level5" = @level5
)
AND (@pollingStationId IS NULL OR QR."PollingStationId" = @pollingStationId)
AND (@fromDate is NULL OR QR."LastUpdatedAt" >= @fromDate::timestamp)
AND (@toDate is NULL OR QR."LastUpdatedAt" <= @toDate::timestamp)
AND (@hasAttachments IS NULL
Expand Down Expand Up @@ -145,6 +146,7 @@ @level4 IS NULL
@level5 IS NULL
OR PS."Level5" = @level5
)
AND (@pollingStationId IS NULL OR QR."PollingStationId" = @pollingStationId)
AND (@fromDate is NULL OR QR."LastUpdatedAt" >= @fromDate::timestamp)
AND (@toDate is NULL OR QR."LastUpdatedAt" <= @toDate::timestamp)
AND (@hasAttachments IS NULL
Expand Down Expand Up @@ -204,6 +206,7 @@ FETCH NEXT
toDate = req.ToDateFilter?.ToString("O"),
hasAttachments = req.HasAttachments,
monitoringObserverId = req.MonitoringObserverId,
pollingStationId = req.PollingStationId,
tagsFilter = req.TagsFilter ?? [],
sortExpression = GetSortExpression(req.SortColumnName, req.IsAscendingSorting)
};
Expand Down
1 change: 1 addition & 0 deletions api/src/Feature.QuickReports/List/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ public class Request : BaseSortPaginatedRequest
[QueryParam] public Guid? CoalitionMemberId { get; set; }
[QueryParam] public bool? HasAttachments { get; set; }
[QueryParam] public Guid? MonitoringObserverId { get; set; }
[QueryParam] public Guid? PollingStationId { get; set; }
[QueryParam] public string[]? TagsFilter { get; set; } = [];
}
Loading
Loading