Added method to get locations count by type

Also, splitted core changes from PR: https://github.com/dimagi/commcare-hq/pull/3839