Question on totalSize function
Opened this issue · 1 comments
acondolu commented
While adding documentation I stumbled upon the function totalSize
in Admin.hs
:
totalSize :: MonadIO m => Collection -> Action m Int
totalSize coll = do
x <- storageSize coll
xs <- mapM isize =<< getIndexes coll
return (foldl (+) x xs)
where
isize idx = at "storageSize" `liftM` collectionStats (coll `T.append` ".$" `T.append` at "name" idx)
The function sums the storage size of a collection with the (separately computed) sizes of its indices. What is strange to me is that collectionStats
is called on things that are not collections, but indices.
Why not just using the totalIndexSize
function (defined just above totalSize
) i.e. something like:
totalSize coll = liftM2 (+) (storageSize coll) (totalIndexSize coll)
VictorDenisov commented
It definitely looks suspicious. However since this is part of public API I would refrain from modifying this method's behavior even though it seems broken.