2016-12-11 11:53:03 +01:00
|
|
|
package count
|
|
|
|
|
2016-12-11 14:50:01 +01:00
|
|
|
import (
|
2018-04-27 16:25:01 +02:00
|
|
|
"log"
|
|
|
|
"time"
|
|
|
|
|
2018-04-24 10:28:23 +02:00
|
|
|
"github.com/usefathom/fathom/pkg/datastore"
|
2016-12-11 11:53:03 +01:00
|
|
|
)
|
|
|
|
|
2016-12-24 15:14:25 +02:00
|
|
|
// CreateVisitorTotals aggregates visitor data into daily totals
|
2016-12-25 18:24:53 +02:00
|
|
|
func CreateVisitorTotals(since string) {
|
2018-04-27 16:25:01 +02:00
|
|
|
tomorrow := time.Now().AddDate(0, 0, 1).Format("2006-01-02")
|
|
|
|
totals, err := datastore.VisitorCountPerDay(tomorrow, since)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2016-12-24 13:07:33 +02:00
|
|
|
|
2018-04-27 16:25:01 +02:00
|
|
|
err = datastore.SaveVisitorTotals(totals)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
2016-12-11 16:23:13 +01:00
|
|
|
}
|
2018-04-27 16:25:01 +02:00
|
|
|
|
2016-12-11 16:23:13 +01:00
|
|
|
}
|