Add a few things
This commit is contained in:
@@ -68,6 +68,17 @@ locations
|
||||
:: Q Postgres GarfieldDb s (LocationT (QExpr Postgres s))
|
||||
locations = all_ garfieldDb.locations
|
||||
|
||||
getSnacksByItemId
|
||||
:: InventoryItemId
|
||||
-> Q Postgres GarfieldDb s (SnackT (QExpr Postgres s))
|
||||
getSnacksByItemId item = do
|
||||
im <- all_ garfieldDb.inventoryMap
|
||||
sn <- related_ garfieldDb.snacks im.snackId
|
||||
sa <- oneToOne_ garfieldDb.snacksAvailable (.snackId) sn
|
||||
guard_ $ im.inventoryId ==. val_ item
|
||||
guard_ $ sa.available
|
||||
pure sn
|
||||
|
||||
-- Inserts
|
||||
|
||||
runInserts
|
||||
@@ -76,6 +87,14 @@ runInserts
|
||||
-> IO ()
|
||||
runInserts conn is = runBeamPostgresDebug putStrLn conn $ mapM_ runInsert is
|
||||
|
||||
adjustInventory
|
||||
:: InventoryItemId
|
||||
-> Int64
|
||||
-> Text
|
||||
-> SqlInsert Postgres CorrectionT
|
||||
adjustInventory item amount desc = insert garfieldDb.inventoryCorrections $
|
||||
insertExpressions [Correction (val_ item) default_ (val_ amount) (val_ desc)]
|
||||
|
||||
transfer
|
||||
:: InventoryItemId -- ^ to
|
||||
-> InventoryItemId -- ^ from
|
||||
|
||||
Reference in New Issue
Block a user