Various StatsRepository fixes
@@ -121,8 +121,9 @@ namespace MiningCore.Persistence.Postgres.Repositories
var lastUpdate = con.QuerySingleOrDefault<DateTime?>(query, new { poolId, miner }, tx);
- if (lastUpdate.HasValue)
- {
+ if (!lastUpdate.HasValue)
+ return null;
+
// load rows rows by timestamp
query = "SELECT * FROM minerstats WHERE poolid = @poolId AND miner = @miner AND created = @created";
@@ -155,7 +156,6 @@ namespace MiningCore.Persistence.Postgres.Repositories
};
}
}
- }
return result;
}
@@ -170,14 +170,21 @@ namespace MiningCore.Persistence.Postgres.Repositories
"GROUP BY date_trunc('hour', created), worker " +
"ORDER BY created, worker;";
- var entitiesByDate = con.Query<Entities.MinerWorkerPerformanceStats>(query, new { poolId, miner, start, end })
- .ToArray()
+ var entities = con.Query<Entities.MinerWorkerPerformanceStats>(query, new { poolId, miner, start, end })
+ .ToArray();
+
+ // ensure worker is not null
+ foreach (var entity in entities)
+ entity.Worker = entity.Worker ?? string.Empty;
+
+ // group
+ var entitiesByDate = entities
.GroupBy(x=> x.Created);
var result = entitiesByDate.Select(x => new WorkerPerformanceStatsContainer
{
Created = x.Key,
- Workers = x.ToDictionary(y => y.Worker, y => new WorkerPerformanceStats
+ Workers = x.ToDictionary(y => y.Worker ?? string.Empty, y => new WorkerPerformanceStats
{
Hashrate = y.Hashrate,
SharesPerSecond = y.SharesPerSecond
