mirror of
https://github.com/status-im/fathom.git
synced 2025-02-28 19:10:36 +00:00
Get rid of /api/countries endpoint for now.
This commit is contained in:
parent
cd8e3c3d9a
commit
7dc7dee2f4
@ -1,30 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/dannyvankooten/ana/count"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// URL: /api/countries
|
||||
var GetCountriesHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
before, after := getRequestedPeriods(r)
|
||||
|
||||
// get total
|
||||
total := count.Visitors(before, after)
|
||||
|
||||
// get rows
|
||||
results := count.Custom(`
|
||||
SELECT
|
||||
v.country,
|
||||
COUNT(DISTINCT(pv.visitor_id)) AS count
|
||||
FROM pageviews pv
|
||||
LEFT JOIN visitors v ON v.id = pv.visitor_id
|
||||
WHERE UNIX_TIMESTAMP(pv.timestamp) <= ? AND UNIX_TIMESTAMP(pv.timestamp) >= ? AND v.country IS NOT NULL
|
||||
GROUP BY v.country
|
||||
ORDER BY count DESC
|
||||
LIMIT ?`, before, after, getRequestedLimit(r), total)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(results)
|
||||
})
|
@ -26,7 +26,7 @@ func startServer(port int) {
|
||||
r.Handle("/api/languages", api.Authorize(api.GetLanguagesHandler)).Methods("GET")
|
||||
r.Handle("/api/referrers", api.Authorize(api.GetReferrersHandler)).Methods("GET")
|
||||
r.Handle("/api/screen-resolutions", api.Authorize(api.GetScreenResolutionsHandler)).Methods("GET")
|
||||
r.Handle("/api/countries", api.Authorize(api.GetCountriesHandler)).Methods("GET")
|
||||
//r.Handle("/api/countries", api.Authorize(api.GetCountriesHandler)).Methods("GET")
|
||||
r.Handle("/api/browsers", api.Authorize(api.GetBrowsersHandler)).Methods("GET")
|
||||
|
||||
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user