mirror of
https://github.com/Kugelschieber/marvinblum.git
synced 2026-01-18 06:40:27 +00:00
Updated pirsch, need to implement the new interface.
This commit is contained in:
2
go.mod
2
go.mod
@@ -7,7 +7,7 @@ require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/emvi/api-go v0.2.2
|
||||
github.com/emvi/logbuch v1.1.1
|
||||
github.com/emvi/pirsch v1.4.3
|
||||
github.com/emvi/pirsch v1.5.0
|
||||
github.com/go-sql-driver/mysql v1.5.0 // indirect
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/gosimple/slug v1.9.0
|
||||
|
||||
4
go.sum
4
go.sum
@@ -23,6 +23,10 @@ github.com/emvi/pirsch v1.4.1 h1:YQi54C9bVcCW0UeE6eebZrYlQPMbkbY4SIQr15MV240=
|
||||
github.com/emvi/pirsch v1.4.1/go.mod h1:GDijqLHM331iWtmDmc7th19RxDrZadRkKoNvd9/kDX8=
|
||||
github.com/emvi/pirsch v1.4.2 h1:ULIerXypOW4Rvc8xyP5ZhxehBYqw1Zw35OGNtCIcEPQ=
|
||||
github.com/emvi/pirsch v1.4.2/go.mod h1:GDijqLHM331iWtmDmc7th19RxDrZadRkKoNvd9/kDX8=
|
||||
github.com/emvi/pirsch v1.4.3 h1:Km7Jph8tATJIQIjMTF2iYyGYjgCqt5D9AD2sBoYQJIU=
|
||||
github.com/emvi/pirsch v1.4.3/go.mod h1:GDijqLHM331iWtmDmc7th19RxDrZadRkKoNvd9/kDX8=
|
||||
github.com/emvi/pirsch v1.5.0 h1:3813YrIqN1W5q8v+NrzEHAqKrks3jike3xUmEPsG/8E=
|
||||
github.com/emvi/pirsch v1.5.0/go.mod h1:GDijqLHM331iWtmDmc7th19RxDrZadRkKoNvd9/kDX8=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
|
||||
46
main.go
46
main.go
@@ -144,33 +144,33 @@ func serveTracking() http.HandlerFunc {
|
||||
endDate = time.Now().UTC()
|
||||
}
|
||||
|
||||
totalVisitorsLabels, totalVisitorsDps := tracking.GetTotalVisitors(startDate, endDate)
|
||||
hourlyVisitorsLabels, hourlyVisitorsDps := tracking.GetHourlyVisitors(startDate, endDate)
|
||||
hourlyVisitorsTodayLabels, hourlyVisitorsTodayDps := tracking.GetHourlyVisitorsToday()
|
||||
//totalVisitorsLabels, totalVisitorsDps := tracking.GetTotalVisitors(startDate, endDate)
|
||||
//hourlyVisitorsLabels, hourlyVisitorsDps := tracking.GetHourlyVisitors(startDate, endDate)
|
||||
//hourlyVisitorsTodayLabels, hourlyVisitorsTodayDps := tracking.GetHourlyVisitorsToday()
|
||||
tplCache.RenderWithoutCache(w, "tracking.html", struct {
|
||||
Start int
|
||||
StartDate time.Time
|
||||
EndDate time.Time
|
||||
TotalVisitorsLabels template.JS
|
||||
TotalVisitorsDps template.JS
|
||||
PageVisits []tracking.PageVisits
|
||||
Pages []pirsch.Stats
|
||||
Languages []pirsch.Stats
|
||||
Referrer []pirsch.Stats
|
||||
Browser []pirsch.Stats
|
||||
OS []pirsch.Stats
|
||||
Platform *pirsch.Stats
|
||||
HourlyVisitorsLabels template.JS
|
||||
HourlyVisitorsDps template.JS
|
||||
HourlyVisitorsTodayLabels template.JS
|
||||
HourlyVisitorsTodayDps template.JS
|
||||
ActiveVisitors int
|
||||
ActiveVisitorPages []pirsch.Stats
|
||||
Start int
|
||||
StartDate time.Time
|
||||
EndDate time.Time
|
||||
//TotalVisitorsLabels template.JS
|
||||
//TotalVisitorsDps template.JS
|
||||
//PageVisits []tracking.PageVisits
|
||||
//Pages []pirsch.Stats
|
||||
//Languages []pirsch.Stats
|
||||
//Referrer []pirsch.Stats
|
||||
//Browser []pirsch.Stats
|
||||
//OS []pirsch.Stats
|
||||
//Platform *pirsch.Stats
|
||||
//HourlyVisitorsLabels template.JS
|
||||
//HourlyVisitorsDps template.JS
|
||||
//HourlyVisitorsTodayLabels template.JS
|
||||
//HourlyVisitorsTodayDps template.JS
|
||||
//ActiveVisitors int
|
||||
//ActiveVisitorPages []pirsch.Stats
|
||||
}{
|
||||
start,
|
||||
startDate,
|
||||
endDate,
|
||||
totalVisitorsLabels,
|
||||
/*totalVisitorsLabels,
|
||||
totalVisitorsDps,
|
||||
tracking.GetPageVisits(startDate, endDate),
|
||||
tracking.GetPages(startDate, endDate),
|
||||
@@ -184,7 +184,7 @@ func serveTracking() http.HandlerFunc {
|
||||
hourlyVisitorsTodayLabels,
|
||||
hourlyVisitorsTodayDps,
|
||||
tracking.GetActiveVisitors(),
|
||||
tracking.GetActiveVisitorPages(),
|
||||
tracking.GetActiveVisitorPages(),*/
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<input type="submit" value="Update" />
|
||||
</form>
|
||||
</section>
|
||||
<section>
|
||||
{{/*<section>
|
||||
<h2>Active Visitors</h2>
|
||||
<p>
|
||||
Active visitors within the last five minutes: {{.ActiveVisitors}}
|
||||
@@ -292,6 +292,6 @@
|
||||
}
|
||||
});
|
||||
{{end}}
|
||||
</script>
|
||||
</script>*/}}
|
||||
|
||||
{{template "end.html"}}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package tracking
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/emvi/logbuch"
|
||||
"github.com/emvi/pirsch"
|
||||
"html/template"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -19,7 +15,7 @@ type PageVisits struct {
|
||||
Data template.JS
|
||||
}
|
||||
|
||||
func GetTotalVisitors(startDate, endDate time.Time) (template.JS, template.JS) {
|
||||
/*func GetTotalVisitors(startDate, endDate time.Time) (template.JS, template.JS) {
|
||||
visitors, err := analyzer.Visitors(&pirsch.Filter{From: startDate, To: endDate})
|
||||
|
||||
if err != nil {
|
||||
@@ -31,7 +27,7 @@ func GetTotalVisitors(startDate, endDate time.Time) (template.JS, template.JS) {
|
||||
}
|
||||
|
||||
func GetPageVisits(startDate, endDate time.Time) []PageVisits {
|
||||
visits, err := analyzer.PageVisits(&pirsch.Filter{From: startDate, To: endDate})
|
||||
visits, err := analyzer.PageVisitors(&pirsch.Filter{From: startDate, To: endDate})
|
||||
|
||||
if err != nil {
|
||||
logbuch.Error("Error reading page statistics", logbuch.Fields{"err": err})
|
||||
@@ -126,17 +122,6 @@ func GetPlatform(startDate, endDate time.Time) *pirsch.Stats {
|
||||
return platform
|
||||
}
|
||||
|
||||
func GetHourlyVisitors(startDate, endDate time.Time) (template.JS, template.JS) {
|
||||
visitors, err := analyzer.HourlyVisitors(&pirsch.Filter{From: startDate, To: endDate})
|
||||
|
||||
if err != nil {
|
||||
logbuch.Error("Error reading hourly visitors", logbuch.Fields{"err": err})
|
||||
return "", ""
|
||||
}
|
||||
|
||||
return getLabelsAndDataHourly(visitors)
|
||||
}
|
||||
|
||||
func GetHourlyVisitorsToday() (template.JS, template.JS) {
|
||||
visitors, err := analyzer.HourlyVisitors(&pirsch.Filter{From: today(), To: today()})
|
||||
|
||||
@@ -196,7 +181,7 @@ func getLabelsAndDataHourly(visitors []pirsch.Stats) (template.JS, template.JS)
|
||||
labelsStr := labels.String()
|
||||
dataStr := dp.String()
|
||||
return template.JS(labelsStr[:len(labelsStr)-1]), template.JS(dataStr[:len(dataStr)-1])
|
||||
}
|
||||
}*/
|
||||
|
||||
func today() time.Time {
|
||||
now := time.Now()
|
||||
|
||||
@@ -55,7 +55,7 @@ func NewTracker() (*pirsch.Tracker, context.CancelFunc) {
|
||||
ReferrerDomainBlacklistIncludesSubdomains: true,
|
||||
})
|
||||
analyzer = pirsch.NewAnalyzer(store)
|
||||
processor := pirsch.NewProcessor(store, nil)
|
||||
processor := pirsch.NewProcessor(store)
|
||||
cancel := pirsch.RunAtMidnight(func() {
|
||||
processTrackingData(processor)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user