mirror of https://github.com/status-im/fathom.git
20 lines
432 B
Go
20 lines
432 B
Go
|
package count
|
||
|
|
||
|
import(
|
||
|
"github.com/dannyvankooten/ana/db"
|
||
|
)
|
||
|
|
||
|
func TotalVisitors(before int64, after int64) float64 {
|
||
|
// get total
|
||
|
stmt, err := db.Conn.Prepare(`
|
||
|
SELECT
|
||
|
SUM(a.count)
|
||
|
FROM archive a
|
||
|
WHERE a.metric = 'visitors' AND UNIX_TIMESTAMP(a.date) <= ? AND UNIX_TIMESTAMP(a.date) >= ?`)
|
||
|
checkError(err)
|
||
|
defer stmt.Close()
|
||
|
var total float64
|
||
|
stmt.QueryRow(before, after).Scan(&total)
|
||
|
return total
|
||
|
}
|