Commit 4379e338 authored by Andres Käver's avatar Andres Käver
Browse files

.net upgrade, filtering in sessions

parent ba6ba56f
Pipeline #831 passed with stages
in 1 minute and 43 seconds
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Text.Json" Version="4.7.1" /> <PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -21,9 +22,9 @@ namespace BLL.App.Services ...@@ -21,9 +22,9 @@ namespace BLL.App.Services
} }
public virtual async Task<IEnumerable<GpsSessionView>> GetAllForViewAsync() public virtual async Task<IEnumerable<GpsSessionView>> GetAllForViewAsync(int minLocationsCount = 10, double minDuration = 60, double minDistance = 10, DateTime? fromDateTime = null, DateTime? toDateTime = null)
{ {
return (await Repository.GetAllForViewAsync()).Select(e => Mapper.MapGpsSessionView(e)); return (await Repository.GetAllForViewAsync(minLocationsCount, minDuration, minDistance, fromDateTime, toDateTime)).Select(e => Mapper.MapGpsSessionView(e));
} }
} }
} }
\ No newline at end of file
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using DAL.App.DTO; using DAL.App.DTO;
...@@ -10,6 +11,6 @@ namespace Contracts.DAL.App.Repositories ...@@ -10,6 +11,6 @@ namespace Contracts.DAL.App.Repositories
public interface IGpsSessionRepositoryCustom<TGpsSessionView> public interface IGpsSessionRepositoryCustom<TGpsSessionView>
{ {
Task<IEnumerable<TGpsSessionView>> GetAllForViewAsync(); Task<IEnumerable<TGpsSessionView>> GetAllForViewAsync(int minLocationsCount = 10, double minDuration = 60, double minDistance = 10, DateTime? fromDateTime = null, DateTime? toDateTime = null);
} }
} }
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="com.akaver.sportmap.Contracts.Domain" Version="1.0.0" /> <PackageReference Include="com.akaver.sportmap.Contracts.Domain" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.3" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -34,14 +35,29 @@ namespace DAL.App.EF.Repositories ...@@ -34,14 +35,29 @@ namespace DAL.App.EF.Repositories
return result; return result;
} }
public virtual async Task<IEnumerable<GpsSessionView>> GetAllForViewAsync() public virtual async Task<IEnumerable<GpsSessionView>> GetAllForViewAsync(int minLocationsCount = 10,
double minDuration = 60, double minDistance = 10, DateTime? fromDateTime = null,
DateTime? toDateTime = null)
{ {
return await RepoDbSet var query = RepoDbSet
.Include(a => a.GpsSessionType) .Include(a => a.GpsSessionType)
.ThenInclude(a => a!.Name) .ThenInclude(a => a!.Name)
.ThenInclude(a => a!.Translations) .ThenInclude(a => a!.Translations)
.Where(a => a.GpsLocations!.Count >= 10) .Where(a => a.GpsLocations!.Count >= minLocationsCount && a.Duration >= minDuration &&
.OrderByDescending(a => a.RecordedAt) a.Distance >= minDistance);
if (fromDateTime != null)
{
query = query.Where(a => a.RecordedAt >= fromDateTime);
}
if (toDateTime != null)
{
query = query.Where(a => a.RecordedAt <= toDateTime);
}
query = query
.OrderByDescending(a => a.RecordedAt);
var result = await query
.Select(a => new GpsSessionView() .Select(a => new GpsSessionView()
{ {
Id = a.Id, Id = a.Id,
...@@ -59,6 +75,8 @@ namespace DAL.App.EF.Repositories ...@@ -59,6 +75,8 @@ namespace DAL.App.EF.Repositories
GpsSessionType = a.GpsSessionType!.Name, GpsSessionType = a.GpsSessionType!.Name,
UserFirstLastName = a.AppUser!.FirstName + " " + a.AppUser!.LastName, UserFirstLastName = a.AppUser!.FirstName + " " + a.AppUser!.LastName,
}).ToListAsync(); }).ToListAsync();
return result;
} }
} }
} }
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" /> <PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" /> <PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.3" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="com.akaver.sportmap.Contracts.Domain" Version="1.0.0" /> <PackageReference Include="com.akaver.sportmap.Contracts.Domain" Version="1.0.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" /> <PackageReference Include="System.Text.Json" Version="4.7.2" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.5.0" /> <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.5.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.0" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -42,9 +42,11 @@ namespace WebApp.ApiControllers._1._0 ...@@ -42,9 +42,11 @@ namespace WebApp.ApiControllers._1._0
[AllowAnonymous] [AllowAnonymous]
[Produces("application/json")] [Produces("application/json")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<V1DTO.GpsSessionView>))] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<V1DTO.GpsSessionView>))]
public async Task<ActionResult<IEnumerable<V1DTO.GpsSessionView>>> GetGpsSessions() public async Task<ActionResult<IEnumerable<V1DTO.GpsSessionView>>> GetGpsSessions(int minLocationsCount = 10,
double minDuration = 60, double minDistance = 10, DateTime? fromDateTime = null,
DateTime? toDateTime = null)
{ {
var result = await _bll.GpsSessions.GetAllForViewAsync(); var result = await _bll.GpsSessions.GetAllForViewAsync(minLocationsCount, minDuration, minDistance, fromDateTime, toDateTime);
return Ok(result.Select(e => _mapper.MapGpsSessionView(e))); return Ok(result.Select(e => _mapper.MapGpsSessionView(e)));
} }
......
...@@ -10,16 +10,16 @@ ...@@ -10,16 +10,16 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.3.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment