diff --git a/Inspector/Inspector.csproj b/Inspector/Inspector.csproj
index d1a5e8d..e3aebbf 100644
--- a/Inspector/Inspector.csproj
+++ b/Inspector/Inspector.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/Roadie.Api.Library.Tests/Roadie.Library.Tests.csproj b/Roadie.Api.Library.Tests/Roadie.Library.Tests.csproj
index 6464095..6b26faa 100644
--- a/Roadie.Api.Library.Tests/Roadie.Library.Tests.csproj
+++ b/Roadie.Api.Library.Tests/Roadie.Library.Tests.csproj
@@ -20,7 +20,7 @@
-
+
all
diff --git a/Roadie.Api.Library/Data/EntityBase.cs b/Roadie.Api.Library/Data/EntityBase.cs
index b823408..66a27c6 100644
--- a/Roadie.Api.Library/Data/EntityBase.cs
+++ b/Roadie.Api.Library/Data/EntityBase.cs
@@ -26,7 +26,8 @@ namespace Roadie.Library.Data
[Required]
public Guid RoadieId { get; set; }
- [Column("status", TypeName = "enum")]
+
+ [Column("status")]
public Statuses? Status { get; set; }
public EntityBase()
diff --git a/Roadie.Api.Library/Data/RoadieDbContext.cs b/Roadie.Api.Library/Data/RoadieDbContext.cs
index 500de37..d6442db 100644
--- a/Roadie.Api.Library/Data/RoadieDbContext.cs
+++ b/Roadie.Api.Library/Data/RoadieDbContext.cs
@@ -44,6 +44,15 @@ namespace Roadie.Library.Data
{
base.OnModelCreating(builder);
+ //builder
+ // .Entity()
+ // .Property(e => e.Status)
+ // .HasConversion(
+ // v => v.ToString(),
+ // v => string.IsNullOrEmpty(v) ? Statuses.Ok : (Statuses)Enum.Parse(typeof(Statuses), v))
+ // .HasDefaultValue(Statuses.Ok);
+
+
//builder
// .Entity()
// .Property(e => e.Status)
diff --git a/Roadie.Api.Library/Roadie.Library.csproj b/Roadie.Api.Library/Roadie.Library.csproj
index 55005a2..bc3ef80 100644
--- a/Roadie.Api.Library/Roadie.Library.csproj
+++ b/Roadie.Api.Library/Roadie.Library.csproj
@@ -9,22 +9,22 @@
-
-
+
+
-
+
-
+
-
+
-
-
+
+
@@ -32,7 +32,7 @@
-
+
diff --git a/Roadie.Api.Services/Roadie.Api.Services.csproj b/Roadie.Api.Services/Roadie.Api.Services.csproj
index ad7e433..fedf06f 100644
--- a/Roadie.Api.Services/Roadie.Api.Services.csproj
+++ b/Roadie.Api.Services/Roadie.Api.Services.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/Roadie.Api.Services/StatisticsService.cs b/Roadie.Api.Services/StatisticsService.cs
index b3e7883..ba10a55 100644
--- a/Roadie.Api.Services/StatisticsService.cs
+++ b/Roadie.Api.Services/StatisticsService.cs
@@ -32,10 +32,12 @@ namespace Roadie.Api.Services
LibraryStats result = null;
var sw = new Stopwatch();
sw.Start();
- using (var conn = new MySqlConnection(this.Configuration.ConnectionString))
+ try
{
- conn.Open();
- var sql = @"SELECT rm.releaseMediaCount AS releaseMediaCount, COUNT(r.roadieId) AS releaseCount,
+ using (var conn = new MySqlConnection(this.Configuration.ConnectionString))
+ {
+ conn.Open();
+ var sql = @"SELECT rm.releaseMediaCount AS releaseMediaCount, COUNT(r.roadieId) AS releaseCount,
ts.trackCount, ts.trackDuration as TotalTrackDuration, ts.trackSize as TotalTrackSize, ac.artistCount, lc.labelCount, pc.playedCount, uc.userCount, cc.collectionCount, pl.playlistCount
FROM `release` r
INNER JOIN (
@@ -66,53 +68,59 @@ namespace Roadie.Api.Services
INNER JOIN (
SELECT COUNT(1) as playlistCount
FROM `playlist`) pl;";
- using (var cmd = new MySqlCommand(sql, conn))
- {
- try
+ using (var cmd = new MySqlCommand(sql, conn))
{
- using (var rdr = await cmd.ExecuteReaderAsync())
+ try
{
- if (rdr.HasRows)
+ using (var rdr = await cmd.ExecuteReaderAsync())
{
- while (rdr.Read())
+ if (rdr.HasRows)
{
- result = new LibraryStats
+ while (rdr.Read())
{
- UserCount = SafeParser.ToNumber(rdr["UserCount"]),
- CollectionCount = SafeParser.ToNumber(rdr["CollectionCount"]),
- PlaylistCount = SafeParser.ToNumber(rdr["PlaylistCount"]),
- ArtistCount = SafeParser.ToNumber(rdr["ArtistCount"]),
- LabelCount = SafeParser.ToNumber(rdr["LabelCount"]),
- ReleaseCount = SafeParser.ToNumber(rdr["ReleaseCount"]),
- ReleaseMediaCount = SafeParser.ToNumber(rdr["ReleaseMediaCount"]),
- PlayedCount = SafeParser.ToNumber(rdr["PlayedCount"]),
- TrackCount = SafeParser.ToNumber(rdr["TrackCount"]),
- TotalTrackDuration = SafeParser.ToNumber(rdr["TotalTrackDuration"]),
- TotalTrackSize = SafeParser.ToNumber(rdr["TotalTrackSize"])
- };
+ result = new LibraryStats
+ {
+ UserCount = SafeParser.ToNumber(rdr["UserCount"]),
+ CollectionCount = SafeParser.ToNumber(rdr["CollectionCount"]),
+ PlaylistCount = SafeParser.ToNumber(rdr["PlaylistCount"]),
+ ArtistCount = SafeParser.ToNumber(rdr["ArtistCount"]),
+ LabelCount = SafeParser.ToNumber(rdr["LabelCount"]),
+ ReleaseCount = SafeParser.ToNumber(rdr["ReleaseCount"]),
+ ReleaseMediaCount = SafeParser.ToNumber(rdr["ReleaseMediaCount"]),
+ PlayedCount = SafeParser.ToNumber(rdr["PlayedCount"]),
+ TrackCount = SafeParser.ToNumber(rdr["TrackCount"]),
+ TotalTrackDuration = SafeParser.ToNumber(rdr["TotalTrackDuration"]),
+ TotalTrackSize = SafeParser.ToNumber(rdr["TotalTrackSize"])
+ };
+ }
}
}
}
- }
- catch (Exception ex)
- {
- this.Logger.LogError(ex);
- }
- finally
- {
- conn.Close();
+ catch (Exception ex)
+ {
+ this.Logger.LogError(ex);
+ }
+ finally
+ {
+ conn.Close();
+ }
}
}
+ var lastScan = this.DbContext.ScanHistories.OrderByDescending(x => x.CreatedDate).FirstOrDefault();
+ if (lastScan != null)
+ {
+ result.LastScan = lastScan.CreatedDate;
+ }
+ sw.Stop();
+
}
- var lastScan = this.DbContext.ScanHistories.OrderByDescending(x => x.CreatedDate).FirstOrDefault();
- if (lastScan != null)
+ catch (Exception ex)
{
- result.LastScan = lastScan.CreatedDate;
+ this.Logger.LogError(ex);
}
- sw.Stop();
return new OperationResult
{
- IsSuccess = true,
+ IsSuccess = result != null,
OperationTime = sw.ElapsedMilliseconds,
Data = result
};
diff --git a/Roadie.Api/Roadie.Api.csproj b/Roadie.Api/Roadie.Api.csproj
index da5469f..bd6b1d5 100644
--- a/Roadie.Api/Roadie.Api.csproj
+++ b/Roadie.Api/Roadie.Api.csproj
@@ -23,18 +23,18 @@
-
+
-
+
-
+