Correct types

This commit is contained in:
Rene Vergara 2024-08-12 10:42:30 -05:00
parent e24581eb5d
commit 8be9215f04
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

205
src/DB.hs
View file

@ -22,6 +22,7 @@ import Control.Exception (throwIO)
import Control.Monad (forM_, when) import Control.Monad (forM_, when)
import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Logger (NoLoggingT, runNoLoggingT) import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
import Data.Aeson
import Data.Bifunctor (bimap) import Data.Bifunctor (bimap)
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import Data.HexString import Data.HexString
@ -29,140 +30,154 @@ import Data.List (group, sort)
import Data.Maybe (catMaybes, fromJust, isJust) import Data.Maybe (catMaybes, fromJust, isJust)
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.Encoding as TE import qualified Data.Text.Encoding as TE
import Data.Time (UTCTime(..))
import Data.UUID (UUID)
import Data.Word import Data.Word
import Database.Esqueleto.Experimental import Database.Esqueleto.Experimental
import qualified Database.Persist.MySQL as PM import qualified Database.Persist.MySQL as PM
import Database.Persist.TH import Database.Persist.TH
newtype UuidDB = UuidDB
{ getUUID :: UUID
} deriving newtype (Eq, Show, Read, ToJSON, FromJSON)
derivePersistFieldJSON "UuidDB"
newtype HexStringDB = HexStringDB
{ getHex :: HexString
} deriving newtype (Eq, Show, Read)
derivePersistField "HexStringDB"
share share
[mkPersist sqlSettings, mkMigrate "migrateAll"] [mkPersist sqlSettings, mkMigrate "migrateAll"]
[persistLowerCase| [persistLowerCase|
ZgoBlock ZgoBlock json
block_confs Int default=0 confs Int default=0
block_network String default="" network String default=""
block_height Int default=0 height Int default=0
block_time Int default=0 time Int default=0
deriving Show Eq deriving Show Eq
ZgoBlockTx ZgoBlockTx
blocktx_block_id Int blocktx_block_id Int
blocktx_id Int blocktx_id Int
blocktx_txid String blocktx_txid String
deriving Show Eq deriving Show Eq
ZgoCountry ZgoCountry json
country_code String code T.Text
country_name String name T.Text
UniqueCountryCode country_code UniqueCountryCode code
deriving Show Eq deriving Show Eq
ZgoItem ZgoItem json
item_owner_id Int owner_id Int
item_name String name T.Text
item_description T.Text default="" description T.Text default=""
item_cost Float default=0.0 cost Double default=0.0
deriving Show Eq deriving Show Eq
ZgoLanguages ZgoLanguages
encode_id String encode_id T.Text
view_name String default-"" name T.Text default-""
view_element String default="" element T.Text default=""
view_element_text T.Text default="" element_text T.Text default=""
deriving Show Eq deriving Show Eq
ZgoOrders ZgoOrder json
order_zaddress T.Text owner ZgoOwnerId
order_session T.Text session ZgoUserId
order_timestamp Int timestamp Int
order_closed Word8 closed Word8
order_currency String currency T.Text
order_price Float default=0.0 price Double
order_total Float default=0.0 total Double
order_totalzec Float default=0.0 totalzec Double
order_paid Word8 default=0 paid Bool
order_token String default="" token T.Text default=""
order_extinv String default="" externalInvoice T.Text default=""
order_shortcode String default='' shortcode T.Text
order_taxamount Float default=0.0 taxamount Double
order_tipamount Float default=0.0 tipamount Double
order_vatamount Float default=0.0 vatamount Double
deriving Show Eq deriving Show Eq
ZgoOrderLines ZgoOrderLines
orderline_orderid Int default=0 orderId ZgoOrderId
orderline_qty Int default=0 qty Int default=0
orderline_name T.Text default="" name T.Text default=""
orderline_cost Float default=0.0 cost Double default=0.0
deriving Show Eq deriving Show Eq
ZgoOwner ZgoOwner
owner_co_name String default="" co_name T.Text
owner_firstname String firstname T.Text
owner_lastname String lastname T.Text
owner_email String email T.Text
owner_street String street T.Text
owner_city String city T.Text
owner_state String state T.Text
owner_zipcode String zipcode T.Text
owner_phone String phone T.Text
owner_country String country T.Text
owner_website String website T.Text
owner_currency String currency T.Text
owner_zcaddress String zcaddress T.Text
owner_usezats Word8 usezats Bool
owner_crmtoken T.Text crmtoken T.Text
owner_usetax Word8 usetax Bool
owner_taxvalue Float taxvalue Double
owner_usevat Word8 usevat Bool
owner_vat Float vat Double
owner_payconf Word8 payconf Bool
owner_viewkey T.Text viewkey T.Text
owner_invoices Word8 invoices Bool
owner_tips Word8 tips Bool
owner_paid Word8 paid Bool
owner_expiration Int expiration UTCTime
deriving Show Eq deriving Show Eq
ZgoPayment ZgoPayment
payment_delta Int delta Int
payment_done Word8 done Bool
payment_zaddress T.Text zaddress T.Text
payment_session String default="" session UuidDB
payment_blocktime Int default=0 blocktime Int default=0
payment_amount Float default=0.0 amount Double default=0.0
payment_txid String default ="" txid HexStringDB
payment_memo T.Text default="" memo T.Text
deriving Show Eq deriving Show Eq
ZgoPrice ZgoPrice
price_delta Int default=0 price_delta Int default=0
price_done Word8 default=0 price_done Bool default=0
price_zaddress T.Text default="" price_zaddress T.Text default=""
price_session String default="" price_session String default=""
price_blocktime Int default=0 price_blocktime Int default=0
price_amount Float default=0.0 price_amount Double default=0.0
price_txid String default="" price_txid String default=""
price_memo T.Text default="" price_memo T.Text default=""
deriving Show Eq deriving Show Eq
ZgoProsession ZgoProsession
pro_zaddress T.Text default="" zaddress T.Text default=""
pro_expiration Int default=0 expiration UTCTime
pro_closed Word8 default=0 closed Bool
deriving Show Eq deriving Show Eq
ZgoTransaction ZgoTransaction
tx_zaddress T.Text default="" zaddress T.Text default=""
tx_expiration Int default=0 expiration Int default=0
tx_closed Word8 default=0 closed Word8 default=0
deriving Show Eq deriving Show Eq
ZgoUser ZgoUser json
user_zaddress T.Text owner ZgoOwnerId
user_session String session UuidDB
user_blocktime Int blocktime Int
user_pin String pin T.Text
user_validated Word8 default=0 validated Bool
deriving Show Eq deriving Show Eq
ZgoXero ZgoXero
xero_client_id String default="" client_id T.Text default=""
xero_client_secret String default="" client_secret T.Text default=""
deriving Show Eq deriving Show Eq
ZgoXeroToken ZgoXeroToken
xerotoken_zaddress T.Text zaddress T.Text
xerotoken_access_token T.Text access_token T.Text
xerotoken_expires Int expires Int
xerotoken_refreshtoken String refreshtoken T.Text
xerotoken_accexpires Int accexpires Int
xerotoken_accCode String accCode T.Text
xerotoken_refexpires Int refexpires Int
deriving Show Eq deriving Show Eq
|] |]