Add power database support

This commit is contained in:
2019-10-15 19:41:52 -04:00
parent 5bc8018068
commit d970f80278
12 changed files with 209 additions and 14 deletions

View File

@@ -1,11 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace ChrisKaczor.HomeMonitor.Power.Service.Controllers
{
[Route("[controller]")]
[ApiController]
public class ReadingsController : ControllerBase
{
}
}

View File

@@ -0,0 +1,28 @@
using ChrisKaczor.HomeMonitor.Power.Service.Data;
using ChrisKaczor.HomeMonitor.Power.Service.Models;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ChrisKaczor.HomeMonitor.Power.Service.Controllers
{
[Route("[controller]")]
[ApiController]
public class StatusController : ControllerBase
{
private readonly Database _database;
public StatusController(Database database)
{
_database = database;
}
[HttpGet("history-grouped")]
public async Task<ActionResult<List<PowerStatusGrouped>>> GetHistoryGrouped(DateTimeOffset start, DateTimeOffset end, int bucketMinutes = 2)
{
return (await _database.GetStatusHistoryGrouped(start, end, bucketMinutes)).ToList();
}
}
}