CORE-6133 refactored paged-item count logic

It is now its own function.
CORE-6133 folder item count query not considers entity-type
CORE 6133 bad item count query generated by function
CORE-6133 combined duplicate logic query gen logic
CORE-6133 bad count supports entity-type filtering