There's an N+1 bug here caused by calling `cookbook_version.cookbook`. You should be able to use `CookbookVersion.includes(:cookbook).find_each` to eliminate it.