mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-13 17:22:54 -05:00
Change value history to not group
This commit is contained in:
@@ -33,9 +33,9 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("value-history")]
|
||||
public async Task<ActionResult<List<WeatherValue>>> GetValueHistory(WeatherValueType weatherValueType, DateTimeOffset start, DateTimeOffset end, int bucketMinutes = 2)
|
||||
public async Task<ActionResult<List<WeatherValue>>> GetValueHistory(WeatherValueType weatherValueType, DateTimeOffset start, DateTimeOffset end)
|
||||
{
|
||||
return (await _database.GetReadingValueHistory(weatherValueType, start, end, bucketMinutes)).ToList();
|
||||
return (await _database.GetReadingValueHistory(weatherValueType, start, end)).ToList();
|
||||
}
|
||||
|
||||
[HttpGet("history-grouped")]
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Data
|
||||
return await connection.QueryAsync<WeatherReading>(query, new { Start = start, End = end });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<WeatherValue>> GetReadingValueHistory(WeatherValueType weatherValueType, DateTimeOffset start, DateTimeOffset end, int bucketMinutes)
|
||||
public async Task<IEnumerable<WeatherValue>> GetReadingValueHistory(WeatherValueType weatherValueType, DateTimeOffset start, DateTimeOffset end)
|
||||
{
|
||||
await using var connection = CreateConnection();
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Data
|
||||
|
||||
query = query.Replace("@Value", weatherValueType.ToString());
|
||||
|
||||
return await connection.QueryAsync<WeatherValue>(query, new { Start = start, End = end, BucketMinutes = bucketMinutes });
|
||||
return await connection.QueryAsync<WeatherValue>(query, new { Start = start, End = end });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<WeatherReadingGrouped>> GetReadingHistoryGrouped(DateTimeOffset start, DateTimeOffset end, int bucketMinutes)
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
SELECT bucket,
|
||||
AVG(Value) AS AverageValue
|
||||
FROM (
|
||||
SELECT CAST(FORMAT(Timestamp, 'yyyy-MM-ddTHH:') +
|
||||
RIGHT('00' + CAST(DATEPART(MINUTE, Timestamp) / @BucketMinutes * @BucketMinutes AS VARCHAR), 2)
|
||||
+ ':00+00:00' AS DATETIMEOFFSET) AS Bucket,
|
||||
@Value AS Value
|
||||
FROM Reading
|
||||
WHERE Timestamp BETWEEN @Start AND @End
|
||||
) AS Data
|
||||
GROUP BY Bucket
|
||||
ORDER BY Bucket
|
||||
SELECT Timestamp,
|
||||
@Value AS Value
|
||||
FROM Reading
|
||||
WHERE Timestamp BETWEEN @Start AND @End
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace ChrisKaczor.HomeMonitor.Weather.Service.Models
|
||||
[PublicAPI]
|
||||
public class WeatherValue
|
||||
{
|
||||
public DateTimeOffset Bucket { get; set; }
|
||||
public DateTimeOffset Timestamp { get; set; }
|
||||
|
||||
public decimal AverageValue { get; set; }
|
||||
public decimal Value { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user