-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Splitted classes, preparing for limited queries * Added limits to query builder * Fixed warning Co-authored-by: Vsevolod <[email protected]> Co-authored-by: Aleksandr Volochnev <[email protected]>
- Loading branch information
1 parent
f2e8f40
commit 3a1663d
Showing
2 changed files
with
38 additions
and
19 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
simplejson "github.com/bitly/go-simplejson" | ||
) | ||
|
||
type QueryBuilder struct{} | ||
|
||
func (qb *QueryBuilder) MetricQuery(queryData *simplejson.Json, timeRangeFrom string, timeRangeTo string) string { | ||
allowFiltering := "" | ||
if queryData.Get("filtering").MustBool() { | ||
allowFiltering = " ALLOW FILTERING" | ||
} | ||
|
||
preparedQuery := fmt.Sprintf( | ||
"SELECT %s, CAST(%s as double) FROM %s.%s WHERE %s = %s AND %s >= '%s' AND %s <= '%s' %s", | ||
queryData.Get("columnTime").MustString(), | ||
queryData.Get("columnValue").MustString(), | ||
queryData.Get("keyspace").MustString(), | ||
queryData.Get("table").MustString(), | ||
queryData.Get("columnId").MustString(), | ||
queryData.Get("valueId").MustString(), | ||
queryData.Get("columnTime").MustString(), | ||
timeRangeFrom, | ||
queryData.Get("columnTime").MustString(), | ||
timeRangeTo, | ||
allowFiltering, | ||
) | ||
|
||
return preparedQuery | ||
} |