can ignore updates in gallery sort
This commit is contained in:
parent
1a1a2f3be4
commit
5b213f3881
1 changed files with 14 additions and 10 deletions
|
@ -15,13 +15,14 @@ import Date
|
||||||
import Records
|
import Records
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
|
import Control.Monad
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Data.Foldable (find)
|
import Data.Foldable (find)
|
||||||
import Data.Hashable (Hashable)
|
import Data.Hashable (Hashable)
|
||||||
import Data.HashSet (HashSet)
|
import Data.HashSet (HashSet)
|
||||||
import qualified Data.HashSet as HashSet
|
import qualified Data.HashSet as HashSet
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Data.Maybe (isJust, isNothing, fromMaybe)
|
import Data.Maybe (isJust, isNothing, fromMaybe, mapMaybe)
|
||||||
import Data.List (nub, sortBy)
|
import Data.List (nub, sortBy)
|
||||||
import Data.Ord (comparing)
|
import Data.Ord (comparing)
|
||||||
import Data.String (IsString)
|
import Data.String (IsString)
|
||||||
|
@ -93,9 +94,10 @@ data Link =
|
||||||
|
|
||||||
data Update =
|
data Update =
|
||||||
Update {
|
Update {
|
||||||
date :: !Date,
|
date :: !Date,
|
||||||
desc :: !Text,
|
desc :: !Text,
|
||||||
nsfw :: !Bool
|
nsfw :: !Bool,
|
||||||
|
ignoreSort :: !Bool
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
|
@ -129,8 +131,9 @@ instance HasField "mine" Info Bool where getField = isNothing . #artist
|
||||||
instance HasField "notMine" Info Bool where getField = isJust . #artist
|
instance HasField "notMine" Info Bool where getField = isJust . #artist
|
||||||
|
|
||||||
instance HasField "latestDate" Info (Bool -> Date) where
|
instance HasField "latestDate" Info (Bool -> Date) where
|
||||||
getField info@(Info {date}) nsfw =
|
getField info@(Info {date=date₀}) nsfw =
|
||||||
maximum $ date : map #date (updatesFor nsfw info)
|
maximum $ date₀ : mapMaybe relDate (updatesFor nsfw info)
|
||||||
|
where relDate (Update {date, ignoreSort}) = date <$ guard (not ignoreSort)
|
||||||
|
|
||||||
instance HasField "latestYear" Info (Bool -> Int) where
|
instance HasField "latestYear" Info (Bool -> Int) where
|
||||||
getField info nsfw = #year $ #latestDate info nsfw
|
getField info nsfw = #year $ #latestDate info nsfw
|
||||||
|
@ -295,11 +298,12 @@ updateList =
|
||||||
date <- parseYAML date'
|
date <- parseYAML date'
|
||||||
asDesc date rest <|> asObj date rest
|
asDesc date rest <|> asObj date rest
|
||||||
asDesc date = YAML.withStr "desc" \desc ->
|
asDesc date = YAML.withStr "desc" \desc ->
|
||||||
pure $ Update {date, desc, nsfw = False}
|
pure $ Update {date, desc, nsfw = False, ignoreSort = False}
|
||||||
asObj date = YAML.withMap "update info" \m -> do
|
asObj date = YAML.withMap "update info" \m -> do
|
||||||
desc <- m .: "desc"
|
desc <- m .: "desc"
|
||||||
nsfw <- m .:? "nsfw" .!= False
|
nsfw <- m .:? "nsfw" .!= False
|
||||||
pure $ Update {date, desc, nsfw}
|
ignoreSort <- m .:? "ignore-sort" .!= False
|
||||||
|
pure $ Update {date, desc, nsfw, ignoreSort}
|
||||||
|
|
||||||
|
|
||||||
data GalleryInfo =
|
data GalleryInfo =
|
||||||
|
|
Loading…
Reference in a new issue