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

duration calculation

parent 10aa6563
Pipeline #822 passed with stages
in 1 minute and 28 seconds
......@@ -29,7 +29,7 @@ namespace BLL.App.DTO
public DateTime RecordedAt { get; set; }
[Display(Name = nameof(Duration), ResourceType = typeof(Resources.BLL.App.DTO.GpsSession))]
public int Duration { get; set; } // in seconds
public double Duration { get; set; } // in seconds
[Display(Name = nameof(Speed), ResourceType = typeof(Resources.BLL.App.DTO.GpsSession))]
public double Speed { get; set; } // in seconds per kilometer
......
......@@ -11,7 +11,7 @@ namespace BLL.App.DTO
public DateTime RecordedAt { get; set; }
public int Duration { get; set; } // in seconds
public double Duration { get; set; } // in seconds
public double Speed { get; set; } // in seconds per kilometer
public double Distance { get; set; } // in meters
public double Climb { get; set; } // total climb in meters
......
......@@ -48,6 +48,9 @@ namespace BLL.App.Services
{
gpsSession.Descent += vertical;
}
gpsSession.Duration = (gpsSession.RecordedAt - lastLocation.RecordedAt).TotalSeconds;
await UOW.GpsSessions.UpdateAsync(gpsSession);
return base.Add(gpsLocation);
......
......@@ -24,7 +24,7 @@ namespace DAL.App.DTO
public DateTime RecordedAt { get; set; }
public int Duration { get; set; } // in seconds
public double Duration { get; set; } // in seconds
public double Speed { get; set; } // in seconds per kilometer
public double Distance { get; set; } // in meters
public double Climb { get; set; } // total climb in meters
......
......@@ -11,7 +11,7 @@ namespace DAL.App.DTO
public DateTime RecordedAt { get; set; }
public int Duration { get; set; } // in seconds
public double Duration { get; set; } // in seconds
public double Speed { get; set; } // in seconds per kilometer
public double Distance { get; set; } // in meters
public double Climb { get; set; } // total climb in meters
......
using Microsoft.EntityFrameworkCore.Migrations;
namespace DAL.App.EF.Migrations
{
public partial class DurationToDouble : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<double>(
name: "Duration",
table: "GpsSessions",
nullable: false,
oldClrType: typeof(int),
oldType: "int");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "Duration",
table: "GpsSessions",
type: "int",
nullable: false,
oldClrType: typeof(double));
}
}
}
......@@ -158,8 +158,8 @@ namespace DAL.App.EF.Migrations
b.Property<double>("Distance")
.HasColumnType("float");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<double>("Duration")
.HasColumnType("float");
b.Property<Guid>("GpsSessionTypeId")
.HasColumnType("uniqueidentifier");
......
......@@ -24,7 +24,7 @@ namespace Domain.App
[DataType(DataType.DateTime)]
public DateTime RecordedAt { get; set; }
public int Duration { get; set; } // in seconds
public double Duration { get; set; } // in seconds
public double Speed { get; set; } // in seconds per kilometer
public double Distance { get; set; } // in meters
public double Climb { get; set; } // total climb in meters
......
......@@ -23,7 +23,7 @@ namespace PublicApi.DTO.v1
public DateTime RecordedAt { get; set; }
public int Duration { get; set; } // in seconds
public double Duration { get; set; } // in seconds
public double Speed { get; set; } // in seconds per kilometer
public double Distance { get; set; } // in meters
public double Climb { get; set; } // total climb in meters
......
......@@ -11,7 +11,7 @@ namespace PublicApi.DTO.v1
public DateTime RecordedAt { get; set; }
public int Duration { get; set; } // in seconds
public double Duration { get; set; } // in seconds
public double Speed { get; set; } // in seconds per kilometer
public double Distance { get; set; } // in meters
public double Climb { get; set; } // total climb in meters
......
......@@ -26,7 +26,9 @@
<p class="card-text">@Html.DisplayNameFor(model => model.GpsSessionType) - @(item.GpsSessionType!.Name!)</p>
<p class="card-text">@Html.DisplayNameFor(model => model.RecordedAt) - @Html.DisplayFor(model => item.RecordedAt)</p>
<p class="card-text">@Html.DisplayNameFor(model => model.Duration) - @Html.DisplayFor(model => item.Duration)</p>
<p class="card-text">@Html.DisplayNameFor(model => model.Distance) - @Html.DisplayFor(model => item.Distance)</p>
<p class="card-text">@Html.DisplayNameFor(model => model.Distance) - @((item.Distance / 1000.0).ToString("N3"))</p>
<p class="card-text">@Html.DisplayNameFor(model => model.Climb) - @Html.DisplayFor(model => item.Climb)</p>
<p class="card-text">@Html.DisplayNameFor(model => model.Descent) - @Html.DisplayFor(model => item.Descent)</p>
<p class="card-text">@Html.DisplayNameFor(model => model.Speed) - @Html.DisplayFor(model => item.Speed)</p>
<a href="#" class="btn btn-primary">View on map</a>
@if (SignInManager.IsSignedIn(User) && User.IsInRole("admin"))
......
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