<commit_before>{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# OPTIONS -fno-warn-orphans      #-}
module Application
    ( withDevSite
    , withDevelAppPort
    ) where

import Foundation
import Settings
import Yesod.Auth
import Yesod.Default.Config
import Yesod.Default.Main
import Yesod.Default.Util
import Yesod.Logger (Logger)
import Data.Dynamic (Dynamic, toDyn)
import Control.Monad (forM)
import Yesod.Comments.Management
import Yesod.Comments.Storage
import Database.Persist.GenericSql (runMigration)
import qualified Database.Persist.Base as Base

import Handler.About
import Handler.Feed
import Handler.Posts
import Handler.Profile
import Handler.Root
import Handler.Tags

mkYesodDispatch "DevSite" resourcesDevSite

getFaviconR :: Handler ()
getFaviconR = sendFile "image/x-icon" "config/favicon.ico"

getRobotsR :: Handler RepPlain
getRobotsR = return $ RepPlain $ toContent ("User-agent: *" :: String)

withDevSite :: AppConfig DefaultEnv -> Logger -> (Application -> IO a) -> IO ()
withDevSite conf logger f = do
    dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf)
            $ either error return . Base.loadConfig

    Base.withPool (dbconf :: Settings.PersistConfig) $ \p -> do
        Base.runPool dbconf (runMigration migratePosts)    p
        Base.runPool dbconf (runMigration migrateComments) p
        defaultRunner f $ DevSite conf logger p loadDocuments

    where
        loadDocuments :: Handler [Document]
        loadDocuments = do
            ps <- runDB $ selectList [] [Desc PostDate]
            ts <- runDB $ selectList [] [Asc  TagName ]
            forM ps $ \(k,v) -> do
                let ts' = filter ((== k) . tagPost) $ map snd ts
                return $ Document v ts'

withDevelAppPort :: Dynamic
withDevelAppPort = toDyn $ defaultDevelApp withDevSite
<commit_msg>remove more provided function<commit_after>{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS -fno-warn-orphans      #-}
module Application
    ( withDevSite
    , withDevelAppPort
    ) where

import Foundation
import Settings
import Yesod.Auth
import Yesod.Default.Config
import Yesod.Default.Main
import Yesod.Default.Util
import Yesod.Default.Handlers
import Yesod.Logger (Logger)
import Data.Dynamic (Dynamic, toDyn)
import Control.Monad (forM)
import Yesod.Comments.Management
import Yesod.Comments.Storage
import Database.Persist.GenericSql (runMigration)
import qualified Database.Persist.Base as Base

import Handler.About
import Handler.Feed
import Handler.Posts
import Handler.Profile
import Handler.Root
import Handler.Tags

mkYesodDispatch "DevSite" resourcesDevSite

withDevSite :: AppConfig DefaultEnv -> Logger -> (Application -> IO a) -> IO ()
withDevSite conf logger f = do
    dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf)
            $ either error return . Base.loadConfig

    Base.withPool (dbconf :: Settings.PersistConfig) $ \p -> do
        Base.runPool dbconf (runMigration migratePosts)    p
        Base.runPool dbconf (runMigration migrateComments) p
        defaultRunner f $ DevSite conf logger p loadDocuments

    where
        loadDocuments :: Handler [Document]
        loadDocuments = do
            ps <- runDB $ selectList [] [Desc PostDate]
            ts <- runDB $ selectList [] [Asc  TagName ]
            forM ps $ \(k,v) -> do
                let ts' = filter ((== k) . tagPost) $ map snd ts
                return $ Document v ts'

withDevelAppPort :: Dynamic
withDevelAppPort = toDyn $ defaultDevelApp withDevSite

{'fraction_non_alphanumeric': 0.09073359073359073, 'fraction_numerical': 0.0, 'mean_word_length': 3.2421052631578946, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '710481', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1044, 'n_words': 308}