Update code formatting

This commit is contained in:
Rene Vergara 2023-09-27 13:42:51 -05:00
parent fb436f1499
commit 4c13ddcc48
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -14,8 +14,7 @@ import Database.MongoDB
import GHC.Generics import GHC.Generics
-- | Type to represent a ZGo shop owner/business -- | Type to represent a ZGo shop owner/business
data Owner = data Owner = Owner
Owner
{ o_id :: Maybe ObjectId { o_id :: Maybe ObjectId
, oaddress :: T.Text , oaddress :: T.Text
, oname :: T.Text , oname :: T.Text
@ -41,8 +40,7 @@ data Owner =
, opayconf :: Bool , opayconf :: Bool
, oviewkey :: T.Text , oviewkey :: T.Text
, ocrmToken :: T.Text , ocrmToken :: T.Text
} } deriving (Eq, Show, Generic, Typeable)
deriving (Eq, Show, Generic, Typeable)
instance ToJSON Owner where instance ToJSON Owner where
toJSON (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv eTs pc vk cT) = toJSON (Owner i a n c t tV v vV f l e s ct st p ph w co paid zats inv eTs pc vk cT) =
@ -276,8 +274,7 @@ instance Val Owner where
] ]
-- | Type to represent informational data for Owners from UI -- | Type to represent informational data for Owners from UI
data OwnerData = data OwnerData = OwnerData
OwnerData
{ od_first :: T.Text { od_first :: T.Text
, od_last :: T.Text , od_last :: T.Text
, od_name :: T.Text , od_name :: T.Text
@ -289,8 +286,7 @@ data OwnerData =
, od_email :: T.Text , od_email :: T.Text
, od_website :: T.Text , od_website :: T.Text
, od_phone :: T.Text , od_phone :: T.Text
} } deriving (Eq, Show, Generic)
deriving (Eq, Show, Generic)
instance FromJSON OwnerData where instance FromJSON OwnerData where
parseJSON = parseJSON =
@ -308,8 +304,7 @@ instance FromJSON OwnerData where
ph <- obj .: "phone" ph <- obj .: "phone"
pure $ OwnerData f l n s c st p co e w ph pure $ OwnerData f l n s c st p co e w ph
data OwnerSettings = data OwnerSettings = OwnerSettings
OwnerSettings
{ os_id :: Maybe ObjectId { os_id :: Maybe ObjectId
, os_address :: T.Text , os_address :: T.Text
, os_name :: T.Text , os_name :: T.Text
@ -325,8 +320,7 @@ data OwnerSettings =
, os_payconf :: Bool , os_payconf :: Bool
, os_crmToken :: T.Text , os_crmToken :: T.Text
, os_viewKey :: T.Text , os_viewKey :: T.Text
} } deriving (Eq, Show, Generic)
deriving (Eq, Show, Generic)
instance FromJSON OwnerSettings where instance FromJSON OwnerSettings where
parseJSON = parseJSON =
@ -424,6 +418,11 @@ findExpiringOwners now =
["paid" =: True, "expiration" =: ["$lte" =: addUTCTime 172800 now]] ["paid" =: True, "expiration" =: ["$lte" =: addUTCTime 172800 now]]
"owners") "owners")
findWithKeys :: Action IO [Document]
findWithKeys =
rest =<<
find (select ["paid" =: True, "invoices" =: True, "payconf" =: True] "owners")
removePro :: T.Text -> Action IO () removePro :: T.Text -> Action IO ()
removePro o = removePro o =
modify (select ["address" =: o] "owners") ["$set" =: ["invoices" =: False]] modify (select ["address" =: o] "owners") ["$set" =: ["invoices" =: False]]
@ -450,14 +449,12 @@ upsertViewingKey o vk =
modify (select ["_id" =: o_id o] "owners") ["$set" =: ["viewKey" =: vk]] modify (select ["_id" =: o_id o] "owners") ["$set" =: ["viewKey" =: vk]]
-- | Type for a pro session -- | Type for a pro session
data ZGoProSession = data ZGoProSession = ZGoProSession
ZGoProSession
{ ps_id :: Maybe ObjectId { ps_id :: Maybe ObjectId
, psaddress :: T.Text , psaddress :: T.Text
, psexpiration :: UTCTime , psexpiration :: UTCTime
, psclosed :: Bool , psclosed :: Bool
} } deriving (Eq, Show)
deriving (Eq, Show)
instance Val ZGoProSession where instance Val ZGoProSession where
cast' (Doc d) = do cast' (Doc d) = do