Skip to content

Commit

Permalink
Commit this version (it's actually the fastest)
Browse files Browse the repository at this point in the history
  • Loading branch information
ane committed Sep 18, 2010
1 parent 2165bd1 commit dfece63
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Hisg/Core.hs
Expand Up @@ -77,9 +77,9 @@ processFiles = do

formatLog :: String -> IRCLog -> FormatterM String
formatLog chan logf = do
let popular (_, (_, a)) (_, (_, b)) = compare b a
let popular (_, (a, _)) (_, (b, _)) = compare b a
insertHeaders chan
insertScoreboard (take 15 . sortBy popular $ calcMessageStats (contents logf))
insertScoreboard (take 15 . sortBy popular $ calcMessageStats (contents logf))
insertFooter "0.1.0"
getFinalOutput

Expand Down
6 changes: 3 additions & 3 deletions src/Hisg/Formatter.hs
Expand Up @@ -29,7 +29,7 @@ import Hisg.Types
import Hisg.Stats
import Hisg.Misc

import qualified Data.ByteString.Lazy.Char8 as S
import qualified Data.ByteString.Char8 as S

-- | The FormatterM monad provides a data abstraction layer between the formatted content
-- and user input. @addOutput@ and @getOutput@ are the methods used to add and fetch data,
Expand Down Expand Up @@ -75,6 +75,6 @@ insertScoreboard users = do
addOutput "<h2>Top 15 users</h2>"
addOutput $ "<table>\n<tr><th>Nickname</th><th>Lines</th><th>Words</th></tr>"
++ concatMap (\(rank, u) -> "<tr><td><b>" ++ show rank ++ ".</b> "
++ S.unpack (fst u) ++ "</td><td>" ++ show ((snd . snd) u)
++ "</td><td>" ++ show ((fst . snd) u)
++ S.unpack (fst u) ++ "</td><td>" ++ show ((fst . snd) u)
++ "</td><td>" ++ show ((snd . snd) u)
++ "</td></tr>") (zip [1..] users) ++ "</table>"
2 changes: 1 addition & 1 deletion src/Hisg/Parser.hs
Expand Up @@ -49,7 +49,7 @@ decode = getNormalMessage

getNormalMessage :: L.ByteString -> Maybe LogEvent
getNormalMessage msg = case match (compile pattern []) (strict msg) [] of
Just (_:ts:nick:sd) -> Just $ Message (L.fromChunks [ts]) (L.fromChunks [nick]) (L.fromChunks sd)
Just (_:ts:nick:sd) -> Just $ Message ts nick (S.concat sd)
_ -> Nothing
where
strict = S.concat . L.toChunks
Expand Down
4 changes: 2 additions & 2 deletions src/Hisg/Stats.hs
Expand Up @@ -32,7 +32,7 @@ import Control.Monad
import Control.Monad.State
import qualified Data.Map as M
import qualified Data.Set as Set
import qualified Data.ByteString.Lazy.Char8 as S
import qualified Data.ByteString.Char8 as S

import Hisg.Types
import Hisg.MapReduce
Expand Down Expand Up @@ -70,7 +70,7 @@ workMessageStats = do
-- msgs <- takeKicks
--
calcMessageStats :: Log -> [(S.ByteString, (Int, Int))]
calcMessageStats log = evalState (workMessageStats) log
calcMessageStats log = processMessages log

--calcKickStats :: Log -> [(S.ByteString, Int)]
--calcKickStats = evalState (workKickStats)
Expand Down
6 changes: 4 additions & 2 deletions src/Hisg/Types.hs
Expand Up @@ -22,9 +22,11 @@ import Data.List
import Data.Char
import Text.Printf

import qualified Data.ByteString.Lazy.Char8 as L

import qualified Data.ByteString.Char8 as L
import qualified Data.ByteString.Char8 as S

import qualified Data.ByteString.Lazy.Char8 as X
newtype User = User (L.ByteString, Int, Int)

-- Basic types
Expand All @@ -45,7 +47,7 @@ data LogEvent =
| ModeChange Mode
| TopicChange Topic
| KickEvent Kick
| Simple L.ByteString
| Simple X.ByteString

-- Type aliases

Expand Down

0 comments on commit dfece63

Please sign in to comment.