Created
February 7, 2017 10:46
-
-
Save yannski/f6a3ff936121d11be2b1b01ce202af25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func LastMinutesTweets() ([]InfluxValue, error) { | |
queryString := "SELECT SUM('value') FROM 'tweets'" | |
queryString += " WHERE hashtag = '" + config.E["HASHTAG"] + "'" | |
queryString += " AND time >= now() - 60m" | |
queryString += " GROUP BY time(1m) fill(none) ORDER BY time DESC LIMIT 60" | |
return executeQuery(queryString) | |
} | |
func executeQuery(queryString string) ([]InfluxValue, error) { | |
client, _ := influx.NewHTTPClient(influx.HTTPConfig{ | |
Addr: config.InfluxConnectionInformation.Host, | |
Username: config.InfluxConnectionInformation.User, | |
Password: config.InfluxConnectionInformation.Password, | |
}) | |
defer client.Close() | |
response, _ := client.Query(influx.Query{ | |
Command: queryString, | |
Database: config.InfluxConnectionInformation.Database, | |
}) | |
if response.Error() != nil { | |
panic(response.Error()) | |
} | |
return convertResults(response) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment