<commit_before>{-# LANGUAGE TemplateHaskell, FlexibleInstances, MultiParamTypeClasses, CPP #-}

module Records where

import Control.Exception

import Database.DSH
import Database.DSH.Compiler

import Database.HDBC.PostgreSQL
import Database.X100Client

#define getConnectionDef (connectPostgreSQL "user = 'postgres' password='<PASSWORD>' host = 'localhost' dbname = 'onlineForums'")

#define x100Conn (Prelude.return $ x100Info "localhost" "48130" Nothing)
  
getConnection :: IO Connection
getConnection = getConnectionDef

$(generateX100TableRecordInstances x100Conn "spiegel_users"   "User"   [''Show,''Eq,''Ord])
$(generateX100TableRecordInstances x100Conn "spiegel_threads" "Thread" [''Show,''Eq,''Ord])
$(generateX100TableRecordInstances x100Conn "spiegel_posts"   "Post"   [''Show,''Eq,''Ord])
$(generateX100TableRecordInstances x100Conn "spiegel_quotes"  "Quote"  [''Show,''Eq,''Ord])
  
users :: Q [User]
users = tableWithKeys "spiegel_users" [["spiegel_user_url"]]

threads :: Q [Thread]
threads = tableWithKeys "spiegel_threads" [["spiegel_thread_url"]]

posts :: Q [Post]
posts = tableWithKeys "spiegel_posts" [["spiegel_post_url"]]

quotes :: Q [Quote]
quotes = table "spiegel_quotes"

runQ :: (QA a) => Q a -> IO a
runQ q =
  bracket getConnection
          disconnect
          (\conn -> fromQ conn q)

debugQ :: (QA a) => Q a -> IO String
debugQ q =
  bracket getConnection
          disconnect
          (\conn -> debugSQL conn q)
<commit_msg>Redundant code in testcase removed.<commit_after>{-# LANGUAGE TemplateHaskell, FlexibleInstances, MultiParamTypeClasses, CPP #-}

module Records where

import Control.Exception

import Database.DSH
import Database.DSH.Compiler

import Database.X100Client

#define getConnectionDef (connectPostgreSQL "user = 'postgres' password='<PASSWORD>' host = 'localhost' dbname = 'onlineForums'")

#define x100Conn (Prelude.return $ x100Info "localhost" "48130" Nothing)
  
$(generateX100TableRecordInstances x100Conn "spiegel_users"   "User"   [''Show,''Eq,''Ord])
$(generateX100TableRecordInstances x100Conn "spiegel_threads" "Thread" [''Show,''Eq,''Ord])
$(generateX100TableRecordInstances x100Conn "spiegel_posts"   "Post"   [''Show,''Eq,''Ord])
$(generateX100TableRecordInstances x100Conn "spiegel_quotes"  "Quote"  [''Show,''Eq,''Ord])
  
users :: Q [User]
users = tableWithKeys "spiegel_users" [["spiegel_user_url"]]

threads :: Q [Thread]
threads = tableWithKeys "spiegel_threads" [["spiegel_thread_url"]]

posts :: Q [Post]
posts = tableWithKeys "spiegel_posts" [["spiegel_post_url"]]

quotes :: Q [Quote]
quotes = table "spiegel_quotes"

{'fraction_non_alphanumeric': 0.13554100885637274, 'fraction_numerical': 0.029264536003080478, 'mean_word_length': 6.098360655737705, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5737450', 'n_tokens_mistral': 951, 'n_tokens_neox': 849, 'n_words': 205}