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