mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 04:07:14 +03:00
remove eqKeyOrUrl function and replace it with (==)
This commit is contained in:
parent
7e8af946e0
commit
4130f887de
@ -34,7 +34,6 @@ module Guide.Utils
|
||||
-- * Referrers
|
||||
ReferrerView (..),
|
||||
toReferrerView,
|
||||
eqKeyOrUrl,
|
||||
|
||||
-- * IP
|
||||
sockAddrToIP,
|
||||
@ -260,12 +259,10 @@ showKeyword (Just "") = ""
|
||||
showKeyword (Just keyword) = " (\"" <> T.toString keyword <> "\")"
|
||||
showKeyword _ = ""
|
||||
|
||||
toBS :: String -> ByteString
|
||||
toBS = encodeUtf8 . T.pack
|
||||
|
||||
extractQuery :: Url -> Maybe Query
|
||||
extractQuery url = getQuery <$> parse url
|
||||
where
|
||||
toBS = encodeUtf8 . T.pack
|
||||
getQuery = parseQuery . toBS . URI.uriQuery
|
||||
parse = URI.parseURI . T.toString
|
||||
|
||||
@ -288,11 +285,6 @@ toReferrerView url
|
||||
domain = T.pack $ URI.uriRegName uriAuth
|
||||
keyword = extractKeyword url
|
||||
|
||||
eqKeyOrUrl :: ReferrerView -> ReferrerView -> Bool
|
||||
eqKeyOrUrl (RefUrl u1) (RefUrl u2) = u1 == u2
|
||||
eqKeyOrUrl (RefSearchEngine _ k1) (RefSearchEngine _ k2) = k1 == k2
|
||||
eqKeyOrUrl _ _ = False
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- IP
|
||||
----------------------------------------------------------------------------
|
||||
|
@ -237,7 +237,8 @@ renderStats globalState acts = do
|
||||
th_ "Visits"
|
||||
th_ "Unique visitors"
|
||||
tbody_ $ do
|
||||
let rawVisits :: [(Uid Category, Maybe IP)]
|
||||
let rawVisits :: [(Uid Category, Maybe IP
|
||||
)]
|
||||
rawVisits = [(catId, actionIP d) |
|
||||
(Action'CategoryVisit catId, d) <- acts']
|
||||
let visits :: [(Uid Category, (Int, Int))]
|
||||
@ -273,7 +274,7 @@ renderStats globalState acts = do
|
||||
Just (ExternalReferrer r) <- [actionReferrer d]]
|
||||
let sortRefs :: [(Url, Maybe IP)] -> [(ReferrerView, [Maybe IP])]
|
||||
sortRefs = map (fst.head &&& map snd)
|
||||
. groupBy (eqKeyOrUrl `on` fst)
|
||||
. groupBy ((==) `on` fst)
|
||||
. sortBy (comparing fst)
|
||||
. map (over _1 toReferrerView)
|
||||
let visits :: [(ReferrerView, (Int, Int))]
|
||||
|
Loading…
Reference in New Issue
Block a user