might be nice to have a `get_case_ids(domain, type)` function for this. guessing this is copy-pasted quite a bit