Compare commits
4 Commits
da52df1e8f
...
29039f1c20
Author | SHA1 | Date | |
---|---|---|---|
29039f1c20 | |||
c359cdf84a | |||
c91c80c63f | |||
1201987364 |
|
@ -3,7 +3,7 @@
|
|||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Get where
|
||||
module ICAFocus.Get where
|
||||
|
||||
import qualified Network.HTTP.Client as H
|
||||
import qualified Network.HTTP.Client.TLS as H
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
|
||||
import Control.Exception (bracket)
|
||||
import Control.Monad (void, unless)
|
||||
import Data.Int (Int32)
|
||||
import Data.Maybe (listToMaybe)
|
||||
import Control.Monad.Except
|
||||
import qualified Database.PostgreSQL.Typed as PG
|
||||
|
||||
import ICAFocus
|
||||
import ICAFocus.Get
|
||||
|
||||
import DBConfig
|
||||
|
||||
PG.useTPGDatabase myPGDatabase
|
||||
|
||||
data Ingredient = Ingredient Int32
|
||||
deriving (Eq)
|
||||
|
||||
createThing :: PG.PGConnection -> Ingredient -> IO ()
|
||||
createThing pg (Ingredient product_id) =
|
||||
void $ PG.pgExecute pg [PG.pgSQL|INSERT INTO ingredient (product_id) VALUES (${product_id})|]
|
||||
|
||||
main = bracket (PG.pgConnect myPGDatabase) PG.pgDisconnect $ \pg -> do
|
||||
let ing = Ingredient 10
|
||||
createThing pg ing
|
||||
let lök_id = 1282116
|
||||
(runExceptT $ getProduct pg lök_id) >>= \case
|
||||
Right lök -> putStrLn $ "Lökat " ++ show lök
|
||||
Left löklös -> putStrLn $ "Löklös? " ++ show löklös
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
mkdir -p artifacts
|
||||
|
||||
log "Kompilerar backend..."
|
||||
find backend -type f -and -name '*.hs' -print0 \
|
||||
| xargs -0 ghc -o artifacts/Main \
|
||||
| xargs -t0 ghc -o artifacts/Main \
|
||||
-odir artifacts \
|
||||
-hidir artifacts \
|
||||
-tmpdir artifacts
|
||||
|
|
|
@ -50,12 +50,26 @@ setupDb() {
|
|||
|
||||
P="$PWD"
|
||||
clean() {
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
log "Rensar byggnad"
|
||||
rm -rf artifacts
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
build() {
|
||||
source "$P/buildScripts/build.sh"
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
( source "buildScripts/build.sh" )
|
||||
RES=$?
|
||||
cd - >/dev/null
|
||||
return $RES
|
||||
}
|
||||
|
||||
run() {
|
||||
build && {
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
./artifacts/Main
|
||||
cd - >/dev/null
|
||||
}
|
||||
}
|
||||
|
||||
if [ "$IS_OWNER" -ne 0 ] ; then
|
||||
|
@ -68,4 +82,4 @@ log "Redo" "!"
|
|||
|
||||
set +e
|
||||
|
||||
cd - >/dev/null 2>&1
|
||||
cd - >/dev/null
|
||||
|
|
Loading…
Reference in New Issue
Block a user