aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2020-02-21 10:53:17 +0000
committerFelix Hanley <felix@userspace.com.au>2020-02-21 10:53:17 +0000
commit9999fa307bcecf304ef4bf998dc97bf09da46fee (patch)
tree68bb89a79d7405377b586a342c0b82daaffeb2ff
parentb7520ce484864e1d3732cb2a499137a2ffbdddc7 (diff)
downloadsws-9999fa307bcecf304ef4bf998dc97bf09da46fee.tar.gz
sws-9999fa307bcecf304ef4bf998dc97bf09da46fee.tar.bz2
Group by browser
-rw-r--r--user_agent.go2
-rw-r--r--user_agent_set.go8
2 files changed, 6 insertions, 4 deletions
diff --git a/user_agent.go b/user_agent.go
index 6b16466..3f43bd0 100644
--- a/user_agent.go
+++ b/user_agent.go
@@ -57,7 +57,7 @@ func (ua UserAgent) Count() int {
}
func (ua UserAgent) Label() string {
- return ua.Browser() + "/" + ua.BrowserVersion()
+ return ua.Browser() // + "/" + ua.BrowserVersion()
}
func (ua UserAgent) YValue() int {
diff --git a/user_agent_set.go b/user_agent_set.go
index 2504841..6e7456b 100644
--- a/user_agent_set.go
+++ b/user_agent_set.go
@@ -14,20 +14,22 @@ func NewUserAgentSet(hitter Hitter) UserAgentSet {
// TODO
continue
}
- b, ok := out[*h.UserAgentHash]
+ d := detector.New(h.UserAgent.Name)
+ browser, _ := d.Browser()
+ b, ok := out[browser]
if !ok {
b = &UserAgent{
Name: h.UserAgent.Name,
LastSeenAt: h.CreatedAt,
hitSet: &HitSet{},
- ua: detector.New(h.UserAgent.Name),
+ ua: d,
}
}
if b.LastSeenAt.Before(h.CreatedAt) {
b.LastSeenAt = h.CreatedAt
}
b.hitSet.Add(h)
- out[*h.UserAgentHash] = b
+ out[browser] = b
}
return UserAgentSet(out)
}