Would it be useful to have this logic as part of the package.rb and errata.rb elasticsearch modules?  It might avoid duplication if we ever need to do the same for a different scenario.

e.g.
Package.package_ids(repoids)
- or -
Package.package_count(repoids)