Skip to content

Commit

Permalink
[HER-150] Add fuzzy search for camera Ids (#82)
Browse files Browse the repository at this point in the history
* [HER-150] Add fuzzy search for camera Ids

* [HER-150] Fix camera filter

* [HER-150] Change filters for cameras and detections
  • Loading branch information
Urzica-Platon-Casian authored Aug 16, 2021
1 parent a934607 commit e21018a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/Data/Camera/Filtering/CameraFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ namespace Data.Camera.Filtering
{
using System.Linq;
using Business.Camera.Fetching.Models;
using Microsoft.EntityFrameworkCore;
using MySql.EntityFrameworkCore.Extensions;

public class CameraFilter : ICameraFilter
{
Expand All @@ -22,10 +24,9 @@ public IQueryable<ECamera> Execute(IQueryable<ECamera> input)
return MatchGreaterLongitude(input);
}

private IQueryable<ECamera> MatchId(IQueryable<ECamera> input) =>
_parameter.Ids != null
? input.Where(entity => _parameter.Ids.Contains(entity.Id))
: input;
private IQueryable<ECamera> MatchId(IQueryable<ECamera> input) => _parameter.Ids != null
? input.Where(entity => EF.Functions.Like(_parameter.Ids.Contains(entity.Id), $"%{_parameter.Ids}%"))
: input;

private IQueryable<ECamera> MatchLesserLatitude(IQueryable<ECamera> input) =>
_parameter.Latitude.LesserEqualThan != null
Expand Down
3 changes: 2 additions & 1 deletion src/Data/Detection/Filtering/DetectionFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Data.Detection.Filtering
using System.Linq;
using Business.Detection.Fetching.Models;
using Microsoft.EntityFrameworkCore;
using MySql.EntityFrameworkCore.Extensions;

public class DetectionFilter : IDetectionFilter
{
Expand Down Expand Up @@ -55,6 +56,6 @@ private IQueryable<EDetection> MatchTimestampGreaterThan(IQueryable<EDetection>
: input;

private IQueryable<EDetection> MatchCameraIds(IQueryable<EDetection> input) =>
_parameter.CameraIds == null ? input : input.Where(detection => _parameter.CameraIds.Contains(detection.CameraId));
_parameter.CameraIds == null ? input : input.Where(detection => EF.Functions.Like(_parameter.CameraIds.Contains(detection.CameraId), $"%{_parameter.CameraIds}%"));
}
}

0 comments on commit e21018a

Please sign in to comment.