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