)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":9712,"name":"Dougal Matthews","email":"dougal.matthews@canonical.com","username":"dougal"},"change_message_id":"d9a12a81c003994bf9e9a8e03b04b81084850865","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Removed NOT IN query from expiration policy."},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"NOT IN subquery with limit is not supported by some databases,"},{"line_number":10,"context_line":"so instead LEFT JOIN is used accomplish the same thing."},{"line_number":11,"context_line":""},{"line_number":12,"context_line":"Closes-bug: #1712585"},{"line_number":13,"context_line":"Change-Id: Ieeb6629cc6c2fc0794ac9a0ef731816c2b6ea59b"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"7f287b81_cc71eb0e","line":10,"updated":"2017-08-24 07:23:41.000000000","message":"Which databases don\u0027t support this?","commit_id":"df1ff38016b5c4ef011b0ee82c0644f738fc33de"},{"author":{"_account_id":23211,"name":"Kupai József","email":"jozsef.kupai@nokia.com","username":"kupsef"},"change_message_id":"8deac3aa519e5271f8c12eae8ea4c0256d8b6876","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Removed NOT IN query from expiration policy."},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"NOT IN subquery with limit is not supported by some databases,"},{"line_number":10,"context_line":"so instead LEFT JOIN is used accomplish the same thing."},{"line_number":11,"context_line":""},{"line_number":12,"context_line":"Closes-bug: #1712585"},{"line_number":13,"context_line":"Change-Id: Ieeb6629cc6c2fc0794ac9a0ef731816c2b6ea59b"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"7f287b81_2d72a6e4","line":10,"in_reply_to":"7f287b81_cc71eb0e","updated":"2017-08-24 11:34:19.000000000","message":"MySQL and MariaDB are what I\u0027m aware of. There is link in the bug report mentioning this limitation in MariaDB. The same is true for MySQL though.","commit_id":"df1ff38016b5c4ef011b0ee82c0644f738fc33de"}],"mistral/db/v2/sqlalchemy/api.py":[{"author":{"_account_id":6732,"name":"Lingxian Kong","email":"anlin.kong@gmail.com","username":"kong"},"change_message_id":"6f31d8b71b6e8330582dc268e810535d48b6e76a","unresolved":false,"context_lines":[{"line_number":1128,"context_line":"    inverse \u003d inverse.filter(query.c.id.is_(None))"},{"line_number":1129,"context_line":""},{"line_number":1130,"context_line":"    if limit:"},{"line_number":1131,"context_line":"        inverse \u003d inverse.limit(limit)"},{"line_number":1132,"context_line":""},{"line_number":1133,"context_line":"    return inverse.all()"},{"line_number":1134,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"7f287b81_9dcc3a8a","line":1131,"updated":"2017-08-23 22:06:24.000000000","message":"It looks even more complex, why not consider what I suggested in your first implementation. \n\n1. Get the number of all finished executions. If num \u003c max_finished_executions, return directly.\n2. Delete (num - max_finished_executions) finished executions in asc order of \u0027updated_at\u0027\n\nSo that we don\u0027t need subquery, and neither the join.","commit_id":"df1ff38016b5c4ef011b0ee82c0644f738fc33de"},{"author":{"_account_id":23211,"name":"Kupai József","email":"jozsef.kupai@nokia.com","username":"kupsef"},"change_message_id":"8deac3aa519e5271f8c12eae8ea4c0256d8b6876","unresolved":false,"context_lines":[{"line_number":1128,"context_line":"    inverse \u003d inverse.filter(query.c.id.is_(None))"},{"line_number":1129,"context_line":""},{"line_number":1130,"context_line":"    if limit:"},{"line_number":1131,"context_line":"        inverse \u003d inverse.limit(limit)"},{"line_number":1132,"context_line":""},{"line_number":1133,"context_line":"    return inverse.all()"},{"line_number":1134,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"7f287b81_d08a9919","line":1131,"in_reply_to":"7f287b81_9dcc3a8a","updated":"2017-08-24 11:34:19.000000000","message":"Hi, thanks for the response.\n\nI considered it, and actually my first implementation was like that, but it is more complex in the end because of the expiration time constraint. You would need smth like this:\n----------\nnum_all \u003d # count of all completed executions\nnum_expired \u003d # count of all expired/completed executions\n\nmfe \u003d num_all if mfe is None else mfe\n\nexpired_limit \u003d num_expired\nmax_limit \u003d max(num_all - mfe, 0)\nlimit \u003d num_all if limit is None else limit\nlimit_final \u003d min(max(expired_limit, max_limit, 0), limit)\n\nreturn # query completed executions ASC (updated_at) with limit_final\n----------\n\nThis takes 3 queries instead of 1, and a weird calculation of the final_limit.\n\nIn this case I think it is much more easy to declare what we don\u0027t want to be cleaned and take the inverse of it. However, if you still like the alternative better, then I can refactor it. \n\nAnd of course, it is possible that there is a more cleaner way that I missed. Please propose.","commit_id":"df1ff38016b5c4ef011b0ee82c0644f738fc33de"},{"author":{"_account_id":6732,"name":"Lingxian Kong","email":"anlin.kong@gmail.com","username":"kong"},"change_message_id":"45723bcfc71711cff9f3c11590f76aca6e5ae055","unresolved":false,"context_lines":[{"line_number":1128,"context_line":"    inverse \u003d inverse.filter(query.c.id.is_(None))"},{"line_number":1129,"context_line":""},{"line_number":1130,"context_line":"    if limit:"},{"line_number":1131,"context_line":"        inverse \u003d inverse.limit(limit)"},{"line_number":1132,"context_line":""},{"line_number":1133,"context_line":"    return inverse.all()"},{"line_number":1134,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"7f287b81_e1a145ab","line":1131,"in_reply_to":"7f287b81_d08a9919","updated":"2017-08-24 13:23:13.000000000","message":"Given the execution expiry check is not a frequent operation, I prefer code readability and maintainability rather than 1 or 2 more db queries.","commit_id":"df1ff38016b5c4ef011b0ee82c0644f738fc33de"},{"author":{"_account_id":23211,"name":"Kupai József","email":"jozsef.kupai@nokia.com","username":"kupsef"},"change_message_id":"c91454528b32f6699769f386a1c65ae3f833e4bb","unresolved":false,"context_lines":[{"line_number":1128,"context_line":"    inverse \u003d inverse.filter(query.c.id.is_(None))"},{"line_number":1129,"context_line":""},{"line_number":1130,"context_line":"    if limit:"},{"line_number":1131,"context_line":"        inverse \u003d inverse.limit(limit)"},{"line_number":1132,"context_line":""},{"line_number":1133,"context_line":"    return inverse.all()"},{"line_number":1134,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"7f287b81_92353149","line":1131,"in_reply_to":"7f287b81_e1a145ab","updated":"2017-08-24 14:28:04.000000000","message":"I refactored it, but I feel like the previous version was more readable. Or wasn\u0027t?","commit_id":"df1ff38016b5c4ef011b0ee82c0644f738fc33de"},{"author":{"_account_id":8731,"name":"Renat Akhmerov","email":"renat.akhmerov@gmail.com","username":"rakhmerov"},"change_message_id":"631bb2a7655cd70e63a3f029144d8fe224eb7134","unresolved":false,"context_lines":[{"line_number":35,"context_line":"from mistral.db import utils as m_dbutils"},{"line_number":36,"context_line":"from mistral.db.v2.sqlalchemy import filters as db_filters"},{"line_number":37,"context_line":"from mistral.db.v2.sqlalchemy import models"},{"line_number":38,"context_line":"from mistral.db.v2.sqlalchemy.models import WorkflowExecution"},{"line_number":39,"context_line":"from mistral import exceptions as exc"},{"line_number":40,"context_line":"from mistral.services import security"},{"line_number":41,"context_line":"from mistral import utils"}],"source_content_type":"text/x-python","patch_set":2,"id":"9f5c4f37_04694724","line":38,"range":{"start_line":38,"start_character":44,"end_line":38,"end_character":61},"updated":"2017-09-21 07:52:14.000000000","message":"We still have a hacking rule in OpenStack not allowing to import objects (classes, functions). Only modules should be imported.\n\nhttps://docs.openstack.org/hacking/latest/user/hacking.html#imports\n\nIt\u0027s not that we have to follow it but if you happen to send another patchset please fix it.","commit_id":"1b8832c2497e9bc05467537fe8d1c9db4826f68a"},{"author":{"_account_id":23211,"name":"Kupai József","email":"jozsef.kupai@nokia.com","username":"kupsef"},"change_message_id":"32f77040a52989a3ef4cd03eeea3d0204e589384","unresolved":false,"context_lines":[{"line_number":35,"context_line":"from mistral.db import utils as m_dbutils"},{"line_number":36,"context_line":"from mistral.db.v2.sqlalchemy import filters as db_filters"},{"line_number":37,"context_line":"from mistral.db.v2.sqlalchemy import models"},{"line_number":38,"context_line":"from mistral.db.v2.sqlalchemy.models import WorkflowExecution"},{"line_number":39,"context_line":"from mistral import exceptions as exc"},{"line_number":40,"context_line":"from mistral.services import security"},{"line_number":41,"context_line":"from mistral import utils"}],"source_content_type":"text/x-python","patch_set":2,"id":"9f5c4f37_5f26e1b9","line":38,"range":{"start_line":38,"start_character":44,"end_line":38,"end_character":61},"in_reply_to":"9f5c4f37_04694724","updated":"2017-09-21 10:50:27.000000000","message":"The import was removed.\nTy for the link, I\u0027ve never seen it.","commit_id":"1b8832c2497e9bc05467537fe8d1c9db4826f68a"}],"mistral/services/expiration_policy.py":[{"author":{"_account_id":8731,"name":"Renat Akhmerov","email":"renat.akhmerov@gmail.com","username":"rakhmerov"},"change_message_id":"631bb2a7655cd70e63a3f029144d8fe224eb7134","unresolved":false,"context_lines":[{"line_number":75,"context_line":"    )"},{"line_number":76,"context_line":""},{"line_number":77,"context_line":""},{"line_number":78,"context_line":"def _delete_until_depleted(delete_func):"},{"line_number":79,"context_line":"    while True:"},{"line_number":80,"context_line":"        with db_api.transaction():"},{"line_number":81,"context_line":"            execs \u003d delete_func()"}],"source_content_type":"text/x-python","patch_set":3,"id":"9f5c4f37_5ff26608","line":78,"range":{"start_line":78,"start_character":27,"end_line":78,"end_character":38},"updated":"2017-09-21 07:52:14.000000000","message":"I think it should be rather \"fetch_func\" or \"get_func\"?","commit_id":"00af6b075772aa11207c4538280467ce7a91b2b3"},{"author":{"_account_id":23211,"name":"Kupai József","email":"jozsef.kupai@nokia.com","username":"kupsef"},"change_message_id":"32f77040a52989a3ef4cd03eeea3d0204e589384","unresolved":false,"context_lines":[{"line_number":75,"context_line":"    )"},{"line_number":76,"context_line":""},{"line_number":77,"context_line":""},{"line_number":78,"context_line":"def _delete_until_depleted(delete_func):"},{"line_number":79,"context_line":"    while True:"},{"line_number":80,"context_line":"        with db_api.transaction():"},{"line_number":81,"context_line":"            execs \u003d delete_func()"}],"source_content_type":"text/x-python","patch_set":3,"id":"9f5c4f37_bc304b09","line":78,"range":{"start_line":78,"start_character":27,"end_line":78,"end_character":38},"in_reply_to":"9f5c4f37_5ff26608","updated":"2017-09-21 10:50:27.000000000","message":"Indeed","commit_id":"00af6b075772aa11207c4538280467ce7a91b2b3"}]}
