Exemplo n.º 1
0
        public async Task <Dictionary <string, object> > GetLatestSentiment(SentimentTopic topic)
        {
            Dictionary <string, object> ret = new Dictionary <string, object>();

            using (NpgsqlConnection connection = new NpgsqlConnection(NoiseConfigurations.PostgresConnectionString))
            {
                await connection.OpenAsync();

                using (NpgsqlCommand command = new NpgsqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = @"
                        SELECT *
                        FROM sentiments
                        ORDER BY date DESC
                        LIMIT 1";

                    using (var reader = await command.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            ret["topic"]   = topic.ToString();
                            ret["domain"]  = reader.GetFieldValueAsync <string>(3).Result;
                            ret["valence"] = reader.GetFieldValueAsync <double>(2).Result;
                            ret["date"]    = reader.GetFieldValueAsync <DateTime>(1).Result;
                        }
                    }
                }
            }

            return(ret);
        }
Exemplo n.º 2
0
        public async Task <ObjectResult> GetLatestSentiment(SentimentTopic topic)
        {
            Dictionary <string, object> ret = await IOCSentimentManager.GetLatestSentiment(topic);

            return(Ok(ret));
        }