mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge branch 'master' of ops:nuevo-pilosa
This commit is contained in:
commit
aeb00ddcb3
3 changed files with 14 additions and 12 deletions
18
core/http.go
18
core/http.go
|
|
@ -65,17 +65,19 @@ func (self *WebService) HandleQuery(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
database_name := r.Form.Get("db")
|
||||
pql := r.Form.Get("pql")
|
||||
|
||||
defer r.Body.Close()
|
||||
if pql == "" {
|
||||
http.Error(w, "Error reading POST data", http.StatusBadRequest)
|
||||
if database_name == "" {
|
||||
database_name = config.GetString("default_db")
|
||||
}
|
||||
if database_name == "" {
|
||||
http.Error(w, "Provide a database (db)", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
// TODO: we need to get the database name from the query string (for now, hard-coded)
|
||||
if database_name == "" {
|
||||
database_name = "main" //TODO pull this from config DEFAULT
|
||||
pql := r.Form.Get("pql")
|
||||
if pql == "" {
|
||||
http.Error(w, "Provide a valid query string (pql)", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
results := self.service.Executor.RunPQL(database_name, pql)
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
|
|
|||
|
|
@ -103,10 +103,10 @@ func (self *Executor) RunPQL(database_name string, pql string) interface{} {
|
|||
return final
|
||||
|
||||
} else {
|
||||
macros_dir := config.GetString("macros")
|
||||
macros_file := macros_dir + "/" + outer_token + ".js"
|
||||
plugins_dir := config.GetString("plugins")
|
||||
plugins_file := plugins_dir + "/" + outer_token + ".js"
|
||||
filter := query.TokensToString(tokens)
|
||||
query_list := GetMacro(macros_file, filter).(query.PqlList)
|
||||
query_list := GetMacro(plugins_file, filter).(query.PqlList)
|
||||
|
||||
for i, _ := range query_list {
|
||||
qry := query.QueryForPQL(query_list[i].PQL)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ func GetMacro(file_name string, filter string) interface{} {
|
|||
}
|
||||
s := string(file_data[:])
|
||||
|
||||
js := "query_list = (function (filter){" + s + "})('" + filter + "');"
|
||||
js := "query_list = (" + s + ")('" + filter + "');"
|
||||
|
||||
Otto := otto.New()
|
||||
Otto.Run(js)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue