Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with min
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
897 B

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Npgsql;
namespace Worker
{
[ApiController]
public class ResultsController : ControllerBase
{
private IConfiguration _configuration;
public ResultsController(IConfiguration configuration)
{
_configuration = configuration;
}
[HttpGet("/results")]
public async Task<IEnumerable<VoteCount>> Get()
{
using (var connection = new NpgsqlConnection(_configuration.GetConnectionString("postgres")))
{
connection.Open();
return await connection.QueryAsync<VoteCount>("SELECT Vote, COUNT(Id) AS Count FROM votes GROUP BY Vote ORDER BY Vote");
}
}
}
}