mirror of https://github.com/status-im/fathom.git
move pageviews struct to API endpoint
This commit is contained in:
parent
8ebe401684
commit
3a46eda0ee
|
@ -5,9 +5,15 @@ import (
|
|||
|
||||
"github.com/dannyvankooten/ana/count"
|
||||
"github.com/dannyvankooten/ana/db"
|
||||
"github.com/dannyvankooten/ana/models"
|
||||
)
|
||||
|
||||
type pageviews struct {
|
||||
Hostname string
|
||||
Path string
|
||||
Count int
|
||||
CountUnique int
|
||||
}
|
||||
|
||||
// URL: /api/pageviews
|
||||
var GetPageviewsHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
before, after := getRequestedPeriods(r)
|
||||
|
@ -32,9 +38,9 @@ var GetPageviewsHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.R
|
|||
checkError(err)
|
||||
defer rows.Close()
|
||||
|
||||
results := make([]models.Pageviews, 0)
|
||||
results := make([]pageviews, 0)
|
||||
for rows.Next() {
|
||||
var p models.Pageviews
|
||||
var p pageviews
|
||||
err = rows.Scan(&p.Hostname, &p.Path, &p.Count, &p.CountUnique)
|
||||
checkError(err)
|
||||
results = append(results, p)
|
||||
|
|
|
@ -13,13 +13,6 @@ type Pageview struct {
|
|||
Timestamp string
|
||||
}
|
||||
|
||||
type Pageviews struct {
|
||||
Hostname string
|
||||
Path string
|
||||
Count int
|
||||
CountUnique int
|
||||
}
|
||||
|
||||
func (pv *Pageview) Save(conn *sql.DB) error {
|
||||
// prepare statement for inserting data
|
||||
stmt, err := conn.Prepare(`INSERT INTO pageviews (
|
||||
|
|
Loading…
Reference in New Issue