Add some initial history APIs

This commit is contained in:
2019-09-06 17:30:01 -04:00
parent 23d1e779c1
commit 1f1f54706c
6 changed files with 67 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using ChrisKaczor.HomeMonitor.Weather.Models;
using ChrisKaczor.HomeMonitor.Weather.Service.Models;
using Dapper;
using Microsoft.Extensions.Configuration;
using System;
@@ -96,5 +97,16 @@ 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)
{
await using var connection = CreateConnection();
var query = ResourceReader.GetString("ChrisKaczor.HomeMonitor.Weather.Service.Data.Resources.GetReadingValueHistory.sql");
query = query.Replace("@Value", weatherValueType.ToString());
return await connection.QueryAsync<WeatherValue>(query, new { Start = start, End = end, BucketMinutes = bucketMinutes });
}
}
}