Compare commits
4 Commits
da52df1e8f
...
29039f1c20
Author | SHA1 | Date | |
---|---|---|---|
29039f1c20 | |||
c359cdf84a | |||
c91c80c63f | |||
1201987364 |
|
@ -3,7 +3,7 @@
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
module Get where
|
module ICAFocus.Get where
|
||||||
|
|
||||||
import qualified Network.HTTP.Client as H
|
import qualified Network.HTTP.Client as H
|
||||||
import qualified Network.HTTP.Client.TLS as H
|
import qualified Network.HTTP.Client.TLS as H
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
{-# LANGUAGE DataKinds #-}
|
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
|
||||||
|
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
import Control.Monad (void, unless)
|
import Control.Monad.Except
|
||||||
import Data.Int (Int32)
|
|
||||||
import Data.Maybe (listToMaybe)
|
|
||||||
import qualified Database.PostgreSQL.Typed as PG
|
import qualified Database.PostgreSQL.Typed as PG
|
||||||
|
|
||||||
|
import ICAFocus
|
||||||
|
import ICAFocus.Get
|
||||||
|
|
||||||
import DBConfig
|
import DBConfig
|
||||||
|
|
||||||
PG.useTPGDatabase myPGDatabase
|
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
|
main = bracket (PG.pgConnect myPGDatabase) PG.pgDisconnect $ \pg -> do
|
||||||
let ing = Ingredient 10
|
let lök_id = 1282116
|
||||||
createThing pg ing
|
(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
|
set -e
|
||||||
|
|
||||||
mkdir -p artifacts
|
mkdir -p artifacts
|
||||||
|
|
||||||
log "Kompilerar backend..."
|
log "Kompilerar backend..."
|
||||||
find backend -type f -and -name '*.hs' -print0 \
|
find backend -type f -and -name '*.hs' -print0 \
|
||||||
| xargs -0 ghc -o artifacts/Main \
|
| xargs -t0 ghc -o artifacts/Main \
|
||||||
-odir artifacts \
|
-odir artifacts \
|
||||||
-hidir artifacts \
|
-hidir artifacts \
|
||||||
-tmpdir artifacts
|
-tmpdir artifacts
|
||||||
|
|
|
@ -50,12 +50,26 @@ setupDb() {
|
||||||
|
|
||||||
P="$PWD"
|
P="$PWD"
|
||||||
clean() {
|
clean() {
|
||||||
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
log "Rensar byggnad"
|
log "Rensar byggnad"
|
||||||
rm -rf artifacts
|
rm -rf artifacts
|
||||||
|
cd - >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
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
|
if [ "$IS_OWNER" -ne 0 ] ; then
|
||||||
|
@ -68,4 +82,4 @@ log "Redo" "!"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
cd - >/dev/null 2>&1
|
cd - >/dev/null
|
||||||
|
|
Loading…
Reference in New Issue
Block a user