<commit_before>{-# LANGUAGE ViewPatterns, TupleSections, RecordWildCards, ScopedTypeVariables, PatternGuards #-}

module Action.Server(actionServer, actionReplay, action_server_test) where

import Prelude(); import General.Prelude
import Data.List.Extra
import System.FilePath
import Control.Exception
import Control.DeepSeq
import Data.Tuple.Extra
import qualified Language.Javascript.JQuery as JQuery
import qualified Language.Javascript.Flot as Flot
import Data.Version
import Paths_hoogle
import Data.Maybe
import Control.Monad
import System.IO.Extra
import qualified Data.Map as Map
import System.Time.Extra
import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Time.Clock
import Data.Time.Calendar
import System.IO.Unsafe

import Output.Tags
import Query hiding (test)
import Input.Type hiding (test)
import General.Util
import General.Web
import General.Store
import General.Template
import General.Log
import Action.Search
import Action.CmdLine


actionServer :: CmdLine -> IO ()
actionServer Server{..} = do
    let pkg = "output" </> head ([database | database /= ""] ++ ["all"])
    putStrLn $ "Server started on port " ++ show port
    log <- timed "Reading log" $ logCreate (if logs == "" then Left stdout else Right logs) ("hoogle=" `isInfixOf`)
    evaluate time
    storeReadFile (pkg <.> "hoo") $ \store ->
        server log port $ replyServer log store cdn

actionReplay :: CmdLine -> IO ()
actionReplay Replay{..} = withBuffering stdout NoBuffering $ do
    src <- readFile logs
    let qs = [readInput url | _:ip:_:url:_ <- map words $ lines src, ip /= "-"]
    (t,_) <- duration $ storeReadFile "output/all.hoo" $ \store -> do<commit_msg>Change the interesting function to ignore is:ping queries<commit_after>{-# LANGUAGE ViewPatterns, TupleSections, RecordWildCards, ScopedTypeVariables, PatternGuards #-}

module Action.Server(actionServer, actionReplay, action_server_test) where

import Prelude(); import General.Prelude
import Data.List.Extra
import System.FilePath
import Control.Exception
import Control.DeepSeq
import Data.Tuple.Extra
import qualified Language.Javascript.JQuery as JQuery
import qualified Language.Javascript.Flot as Flot
import Data.Version
import Paths_hoogle
import Data.Maybe
import Control.Monad
import System.IO.Extra
import qualified Data.Map as Map
import System.Time.Extra
import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Time.Clock
import Data.Time.Calendar
import System.IO.Unsafe

import Output.Tags
import Query hiding (test)
import Input.Type hiding (test)
import General.Util
import General.Web
import General.Store
import General.Template
import General.Log
import Action.Search
import Action.CmdLine


actionServer :: CmdLine -> IO ()
actionServer Server{..} = do
    let pkg = "output" </> head ([database | database /= ""] ++ ["all"])
    putStrLn $ "Server started on port " ++ show port
    evaluate time
    log <- timed "Reading log" $ logCreate (if logs == "" then Left stdout else Right logs) $
        \x -> "hoogle=" `isInfixOf` x && not ("is:ping" `isInfixOf` x)
    storeReadFile (pkg <.> "hoo") $ \store ->
        server log port $ replyServer log store cdn

actionReplay :: CmdLine -> IO ()
actionReplay Replay{..} = withBuffering stdout NoBuffering $ do
    src <- readFile logs
    let qs = [readInput url | _:ip:_:url:_ <- map words $ lines src, ip /= "-"]
    (t,_) <- duration $ storeReadFile "output/all.hoo" $ \store -> do
{'fraction_non_alphanumeric': 0.10550859807636258, 'fraction_numerical': 0.0005829204313611193, 'mean_word_length': 4.32093023255814, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4585466', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1015, 'n_words': 340}