Skip to content

Commit

Permalink
moving feature tracking after validation
Browse files Browse the repository at this point in the history
  • Loading branch information
untoldone committed Jun 1, 2015
1 parent cb7c222 commit b695f3c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
6 changes: 3 additions & 3 deletions handler/item_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ func ItemHandler (w http.ResponseWriter, req *http.Request) {
source := strings.ToLower(vars["source"])
id := vars["id"]

api.AddFeature(req, "handler:item")
api.AddFeature(req, source)

bloomConn := api.Conn()
searchConn := bloomConn.SearchConnection()

Expand Down Expand Up @@ -79,6 +76,9 @@ func ItemHandler (w http.ResponseWriter, req *http.Request) {

body := map[string]interface{} { "result": found }

api.AddFeature(req, "handler:item")
api.AddFeature(req, source)

api.Render(w, req, http.StatusOK, body)
return
}
6 changes: 3 additions & 3 deletions handler/search_source_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ func SearchSourceHandler (w http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
source := strings.ToLower(vars["source"])

api.AddFeature(req, source)
api.AddFeature(req, "handler:search")

conn := api.Conn()
apiKey, ok := context.Get(req, "api_key").(string)
if !ok {
Expand Down Expand Up @@ -51,6 +48,9 @@ func SearchSourceHandler (w http.ResponseWriter, req *http.Request) {
return
}

api.AddFeature(req, source)
api.AddFeature(req, "handler:search")

api.Render(w, req, http.StatusOK, results)
return
}
4 changes: 2 additions & 2 deletions handler/sources_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ func SourcesHandler (w http.ResponseWriter, req *http.Request) {
conn := api.Conn()
apiKey, ok := context.Get(req, "api_key").(string)

api.AddFeature(req, "handler:sources")

if !ok {
apiKey = ""
}
Expand Down Expand Up @@ -53,5 +51,7 @@ func SourcesHandler (w http.ResponseWriter, req *http.Request) {
}
}

api.AddFeature(req, "handler:sources")

api.Render(w, req, http.StatusOK, map[string][]dataSource{"result": sources})
}
8 changes: 2 additions & 6 deletions handler/yourchart_create_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/gorilla/context"
"github.com/spf13/viper"
"github.com/untoldone/bloomapi/api"

"fmt"
)

func YourChartCreateHandler (w http.ResponseWriter, req *http.Request) {
Expand All @@ -38,8 +36,6 @@ func YourChartCreateHandler (w http.ResponseWriter, req *http.Request) {
return
}

api.AddFeature(req, "handler:yourchart:create")

postResp, err := http.PostForm(yourchartUrl, url.Values{
"username": {username},
"password": {password},
Expand Down Expand Up @@ -74,14 +70,14 @@ func YourChartCreateHandler (w http.ResponseWriter, req *http.Request) {
return
}

fmt.Println(jobId)

err = YourchartAuthorize(apiKey, jobId)
if err != nil {
log.Println(err)
api.Render(w, req, http.StatusInternalServerError, "Internal Server Error")
return
}

api.AddFeature(req, "handler:yourchart:create")

api.Render(w, req, http.StatusOK, decoded)
}
4 changes: 2 additions & 2 deletions handler/yourchart_fetch_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ func YourChartFetchHandler (w http.ResponseWriter, req *http.Request) {
})
return
}

api.AddFeature(req, "handler:yourchart:fetch")

getResp, err := http.Get(yourchartUrl + "/" + id)
body, err := ioutil.ReadAll(getResp.Body)
Expand All @@ -66,5 +64,7 @@ func YourChartFetchHandler (w http.ResponseWriter, req *http.Request) {
return
}

api.AddFeature(req, "handler:yourchart:fetch")

api.Render(w, req, http.StatusOK, decoded)
}
6 changes: 3 additions & 3 deletions handler_compat/npi_item_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ func NpiItemHandler (w http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
npi := vars["npi"]

api.AddFeature(req, "usgov.hhs.npi")
api.AddFeature(req, "handler:legacynpi:item")

conn := api.Conn().SearchConnection()

result, err := conn.Search("usgov.hhs.npi", "main", nil, map[string]interface{} {
Expand Down Expand Up @@ -49,6 +46,9 @@ func NpiItemHandler (w http.ResponseWriter, req *http.Request) {
body := map[string]interface{} {"result": hits[0]}
valuesToStrings(body)

api.AddFeature(req, "usgov.hhs.npi")
api.AddFeature(req, "handler:legacynpi:item")

api.Render(w, req, http.StatusOK, body)
return
}
Expand Down
6 changes: 3 additions & 3 deletions handler_compat/npi_search_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ func NpiSearchHandler (w http.ResponseWriter, req *http.Request) {
return
}

api.AddFeature(req, "usgov.hhs.npi")
api.AddFeature(req, "handler:legacynpi:search")

results, err := handler.Search("usgov.hhs.npi", params, req)
if err != nil {
switch err.(type) {
Expand All @@ -32,6 +29,9 @@ func NpiSearchHandler (w http.ResponseWriter, req *http.Request) {
}

valuesToStrings(results)

api.AddFeature(req, "usgov.hhs.npi")
api.AddFeature(req, "handler:legacynpi:search")

api.Render(w, req, http.StatusOK, results)
return
Expand Down

0 comments on commit b695f3c

Please sign in to comment.