rework to normalize version in db and small cleanups

This commit is contained in:
Lucy Cifferello
2020-06-22 12:47:28 -06:00
parent 57627163ff
commit 25b1786808
10 changed files with 92 additions and 86 deletions

View File

@@ -43,4 +43,4 @@ instance HasAppVersion AppVersion where
appVersionMax :: HasAppVersion a => [a] -> Maybe a
appVersionMax [] = Nothing
appVersionMax as = Just $ maximumBy (\a1 a2 -> version a1 `compare` version a2) as
appVersionMax as = Just $ maximumBy (compare `on` version) as

View File

@@ -62,8 +62,8 @@ instance FromJSONKey AppVersion where
Just x -> pure x
instance PersistField AppVersion where
toPersistValue = toPersistValue @String . show
fromPersistValue = note "" . readMaybe <=< fromPersistValue
toPersistValue = toPersistValue @Text . show
fromPersistValue = note "invalid app version" . readMaybe <=< fromPersistValue
instance PersistFieldSql AppVersion where
sqlType _ = SqlString