newtype Group to ByteString
This may speed up queries for things in groups, due to Eq and Ord being faster.
This commit is contained in:
parent
3f7fe1d325
commit
6f66b53a30
10 changed files with 69 additions and 48 deletions
|
@ -26,11 +26,13 @@ start (name:g:[]) = do
|
|||
allowMessages
|
||||
showStart' "group" (Just name)
|
||||
u <- Remote.nameToUUID name
|
||||
next $ setGroup u g
|
||||
next $ setGroup u (toGroup g)
|
||||
start (name:[]) = do
|
||||
u <- Remote.nameToUUID name
|
||||
liftIO . putStrLn . unwords . S.toList =<< lookupGroups u
|
||||
liftIO . putStrLn . unwords . map fmt . S.toList =<< lookupGroups u
|
||||
stop
|
||||
where
|
||||
fmt (Group g) = decodeBS g
|
||||
start _ = giveup "Specify a repository and a group."
|
||||
|
||||
setGroup :: UUID -> Group -> CommandPerform
|
||||
|
|
|
@ -10,6 +10,7 @@ module Command.GroupWanted where
|
|||
import Command
|
||||
import Logs.PreferredContent
|
||||
import Command.Wanted (performGet, performSet)
|
||||
import Types.Group
|
||||
|
||||
cmd :: Command
|
||||
cmd = noMessages $ command "groupwanted" SectionSetup
|
||||
|
@ -21,9 +22,9 @@ seek :: CmdParams -> CommandSeek
|
|||
seek = withWords (commandAction . start)
|
||||
|
||||
start :: [String] -> CommandStart
|
||||
start (g:[]) = next $ performGet groupPreferredContentMapRaw g
|
||||
start (g:[]) = next $ performGet groupPreferredContentMapRaw (toGroup g)
|
||||
start (g:expr:[]) = do
|
||||
allowMessages
|
||||
showStart' "groupwanted" (Just g)
|
||||
next $ performSet groupPreferredContentSet expr g
|
||||
next $ performSet groupPreferredContentSet expr (toGroup g)
|
||||
start _ = giveup "Specify a group."
|
||||
|
|
|
@ -25,7 +25,7 @@ start :: [String] -> CommandStart
|
|||
start (name:g:[]) = do
|
||||
showStart' "ungroup" (Just name)
|
||||
u <- Remote.nameToUUID name
|
||||
next $ perform u g
|
||||
next $ perform u (toGroup g)
|
||||
start _ = giveup "Specify a repository and a group."
|
||||
|
||||
perform :: UUID -> Group -> CommandPerform
|
||||
|
|
|
@ -167,10 +167,10 @@ genCfg cfg descs = unlines $ intercalate [""]
|
|||
, com $ "(Standard groups: " ++ grouplist ++ ")"
|
||||
, com "(Separate group names with spaces)"
|
||||
]
|
||||
(\(s, u) -> line "group" u $ unwords $ S.toList s)
|
||||
(\(s, u) -> line "group" u $ unwords $ map fromGroup $ S.toList s)
|
||||
(\u -> lcom $ line "group" u "")
|
||||
where
|
||||
grouplist = unwords $ map fromStandardGroup [minBound..]
|
||||
grouplist = unwords $ map (fromGroup . fromStandardGroup) [minBound..]
|
||||
|
||||
preferredcontent = settings cfg descs cfgPreferredContentMap
|
||||
[ com "Repository preferred contents"
|
||||
|
@ -191,7 +191,7 @@ genCfg cfg descs = unlines $ intercalate [""]
|
|||
(\(s, g) -> gline g s)
|
||||
(\g -> gline g "")
|
||||
where
|
||||
gline g val = [ unwords ["groupwanted", g, "=", val] ]
|
||||
gline g val = [ unwords ["groupwanted", fromGroup g, "=", val] ]
|
||||
allgroups = S.unions $ stdgroups : M.elems (cfgGroupMap cfg)
|
||||
stdgroups = S.fromList $ map fromStandardGroup [minBound..maxBound]
|
||||
|
||||
|
@ -204,7 +204,7 @@ genCfg cfg descs = unlines $ intercalate [""]
|
|||
where
|
||||
gline g = com $ unwords
|
||||
[ "standard"
|
||||
, fromStandardGroup g, "=", standardPreferredContent g
|
||||
, fromGroup (fromStandardGroup g), "=", standardPreferredContent g
|
||||
]
|
||||
|
||||
schedule = settings cfg descs cfgScheduleMap
|
||||
|
@ -282,7 +282,7 @@ parseCfg defcfg = go [] defcfg . lines
|
|||
let m = M.insert u (Down t) (cfgTrustMap cfg)
|
||||
in Right $ cfg { cfgTrustMap = m }
|
||||
| setting == "group" =
|
||||
let m = M.insert u (S.fromList $ words val) (cfgGroupMap cfg)
|
||||
let m = M.insert u (S.fromList $ map toGroup $ words val) (cfgGroupMap cfg)
|
||||
in Right $ cfg { cfgGroupMap = m }
|
||||
| setting == "wanted" =
|
||||
case checkPreferredContentExpression val of
|
||||
|
@ -300,7 +300,7 @@ parseCfg defcfg = go [] defcfg . lines
|
|||
case checkPreferredContentExpression val of
|
||||
Just e -> Left e
|
||||
Nothing ->
|
||||
let m = M.insert f val (cfgGroupPreferredContentMap cfg)
|
||||
let m = M.insert (toGroup f) val (cfgGroupPreferredContentMap cfg)
|
||||
in Right $ cfg { cfgGroupPreferredContentMap = m }
|
||||
| setting == "schedule" = case parseScheduledActivities val of
|
||||
Left e -> Left e
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue