)]}'
{"blazar/db/sqlalchemy/api.py":[{"author":{"_account_id":8878,"name":"Masahito Muroi","email":"masahito.muroi@g.softbank.co.jp","username":"masa"},"change_message_id":"c6702f18ef7f09da44ae9641c126b286275e2a4c","unresolved":false,"context_lines":[{"line_number":637,"context_line":"            hosts_query \u003d hosts_query.filter(filt)"},{"line_number":638,"context_line":"        else:"},{"line_number":639,"context_line":"            # looking for extra capabilities matches"},{"line_number":640,"context_line":"            extra_filter \u003d model_query("},{"line_number":641,"context_line":"                models.ComputeHostExtraCapability, get_session()"},{"line_number":642,"context_line":"            ).filter(models.ComputeHostExtraCapability.capability_name \u003d\u003d key"},{"line_number":643,"context_line":"                     ).all()"},{"line_number":644,"context_line":"            if not extra_filter:"},{"line_number":645,"context_line":"                raise db_exc.BlazarDBNotFound("},{"line_number":646,"context_line":"                    id\u003dkey, model\u003d\u0027ComputeHostExtraCapability\u0027)"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f1d235d_8d5c0eee","line":643,"range":{"start_line":640,"start_character":0,"end_line":643,"end_character":28},"updated":"2017-07-11 07:47:26.000000000","message":"Why the query doesn\u0027t have a filter to \u0027key op value\u0027 to filter hosts that match requested extra capabilities?  If the query picks up the \u0027matching_extra_capabilities_hosts\u0027, what the query at the return-statement needs to do is filtering out some hosts which matches \u0027hosts_query\u0027 and are not listed in \u0027matching_extra_capabilities_hosts\u0027.","commit_id":"ad03b1c2ca09be37a53d612fe4138a07c0bca5b2"},{"author":{"_account_id":23840,"name":"Hiroaki Kobayashi","email":"kobayashi.hiroaki@lab.ntt.co.jp","username":"hiro-kobayashi"},"change_message_id":"1a6397d4b579c49003a2bbe28da51517b8e07761","unresolved":false,"context_lines":[{"line_number":654,"context_line":""},{"line_number":655,"context_line":"            # We must also avoid selecting any host which doesn\u0027t have the"},{"line_number":656,"context_line":"            # extra capability present."},{"line_number":657,"context_line":"            all_hosts \u003d [h.id for h in hosts_query.all()]"},{"line_number":658,"context_line":"            extra_filter_hosts \u003d [h.computehost_id for h in extra_filter]"},{"line_number":659,"context_line":"            hosts +\u003d [h for h in all_hosts if h not in extra_filter_hosts]"},{"line_number":660,"context_line":""},{"line_number":661,"context_line":"    return hosts_query.filter(~models.ComputeHost.id.in_(hosts)).all()"},{"line_number":662,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"3f1d235d_addb717b","line":659,"range":{"start_line":657,"start_character":0,"end_line":659,"end_character":74},"updated":"2017-07-10 07:10:07.000000000","message":"It works correctly, but a bit verbose. How about changing L639-653 to create a list of matching hosts (call it matching_hosts), and excluding them from hosts like:\n\nall_hosts \u003d [h.id for h in hosts_query.all()]\nhosts +\u003d [h for h in all_hosts if h not in matching_hosts]","commit_id":"ad03b1c2ca09be37a53d612fe4138a07c0bca5b2"},{"author":{"_account_id":8878,"name":"Masahito Muroi","email":"masahito.muroi@g.softbank.co.jp","username":"masa"},"change_message_id":"c6702f18ef7f09da44ae9641c126b286275e2a4c","unresolved":false,"context_lines":[{"line_number":654,"context_line":""},{"line_number":655,"context_line":"            # We must also avoid selecting any host which doesn\u0027t have the"},{"line_number":656,"context_line":"            # extra capability present."},{"line_number":657,"context_line":"            all_hosts \u003d [h.id for h in hosts_query.all()]"},{"line_number":658,"context_line":"            extra_filter_hosts \u003d [h.computehost_id for h in extra_filter]"},{"line_number":659,"context_line":"            hosts +\u003d [h for h in all_hosts if h not in extra_filter_hosts]"},{"line_number":660,"context_line":""},{"line_number":661,"context_line":"    return hosts_query.filter(~models.ComputeHost.id.in_(hosts)).all()"},{"line_number":662,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"3f1d235d_cd91e648","line":659,"range":{"start_line":657,"start_character":0,"end_line":659,"end_character":74},"in_reply_to":"3f1d235d_addb717b","updated":"2017-07-11 07:47:26.000000000","message":"I agree to move this to L639-653. But querying hosts_query.all() for all extra_capabilities is much costs.","commit_id":"ad03b1c2ca09be37a53d612fe4138a07c0bca5b2"}]}
