fix package stat

You can have a helper function for the same logic for prodDB and warehouseDB. Try not to have repeated code.