combine 2 queries
This commit is contained in:
parent
e006acef22
commit
278adbb726
2 changed files with 13 additions and 18 deletions
|
@ -247,19 +247,18 @@ removeLiveSizeChange u k sc sid =
|
|||
, LiveSizeChangesChange ==. sc
|
||||
]
|
||||
|
||||
getLiveSizeChanges :: SqlPersistM (M.Map UUID [(Key, (SizeChange, SizeChangeId))])
|
||||
getLiveSizeChanges = M.fromListWith (++) . map conv <$> selectList [] []
|
||||
getLiveSizeChangesMap :: SqlPersistM (M.Map UUID [(Key, (SizeChange, SizeChangeId))])
|
||||
getLiveSizeChangesMap = M.fromListWith (++) . map conv <$> getLiveSizeChanges
|
||||
where
|
||||
conv entity =
|
||||
let LiveSizeChanges u k sid sc = entityVal entity
|
||||
in (u, [(k, (sc, sid))])
|
||||
conv (LiveSizeChanges u k sid sc) = (u, [(k, (sc, sid))])
|
||||
|
||||
getLiveSizeChanges' :: SqlPersistM [(UUID, Key, SizeChange)]
|
||||
getLiveSizeChanges' = map conv <$> selectList [] []
|
||||
getLiveSizeChangesList :: SqlPersistM [(UUID, Key, SizeChange)]
|
||||
getLiveSizeChangesList = map conv <$> getLiveSizeChanges
|
||||
where
|
||||
conv entity =
|
||||
let LiveSizeChanges u k _sid sc = entityVal entity
|
||||
in (u, k, sc)
|
||||
conv (LiveSizeChanges u k _sid sc) = (u, k, sc)
|
||||
|
||||
getLiveSizeChanges :: SqlPersistM [LiveSizeChanges]
|
||||
getLiveSizeChanges = map entityVal <$> selectList [] []
|
||||
|
||||
getSizeChanges :: SqlPersistM (M.Map UUID FileSize)
|
||||
getSizeChanges = M.fromList . map conv <$> selectList [] []
|
||||
|
@ -310,7 +309,7 @@ getRecentChanges = map conv <$> selectList [] []
|
|||
- redundant with a recent change. -}
|
||||
clearRecentChanges :: SqlPersistM ()
|
||||
clearRecentChanges = do
|
||||
live <- getLiveSizeChanges'
|
||||
live <- getLiveSizeChangesList
|
||||
if null live
|
||||
then deleteWhere ([] :: [Filter RecentChanges])
|
||||
else do
|
||||
|
@ -354,7 +353,7 @@ recordedRepoOffsets (RepoSizeHandle Nothing) = pure mempty
|
|||
liveRepoOffsets :: RepoSizeHandle -> IO (M.Map UUID SizeOffset)
|
||||
liveRepoOffsets (RepoSizeHandle (Just h)) = H.queryDb h $ do
|
||||
sizechanges <- getSizeChanges
|
||||
livechanges <- getLiveSizeChanges
|
||||
livechanges <- getLiveSizeChangesMap
|
||||
let us = S.toList $ S.fromList $
|
||||
M.keys sizechanges ++ M.keys livechanges
|
||||
M.fromList <$> forM us (go sizechanges livechanges)
|
||||
|
|
|
@ -58,18 +58,14 @@ Planned schedule of work:
|
|||
used. annex.pidlock might otherwise prevent running more than one
|
||||
git-annex at a time.
|
||||
|
||||
, or alternatively
|
||||
when checking a preferred content expression that uses balanced preferred
|
||||
content.
|
||||
|
||||
* The assistant is using NoLiveUpdate, but it should be posssible to plumb
|
||||
a LiveUpdate through it from preferred content checking to location log
|
||||
updating.
|
||||
|
||||
* `git-annex info` in the limitedcalc path in cachedAllRepoData
|
||||
double-counts redundant information from the journal due to using
|
||||
overLocationLogs. In the other path it does not, and this should be fixed
|
||||
for consistency and correctness.
|
||||
overLocationLogs. In the other path it does not (any more; it used to),
|
||||
and this should be fixed for consistency and correctness.
|
||||
|
||||
* getLiveRepoSizes has a filterM getRecentChange over the live updates.
|
||||
This could be optimised to a single sql join. There are usually not many
|
||||
|
|
Loading…
Reference in a new issue