)]}'
{"tools/gerrit-account-inconsistencies/audit-users.py":[{"author":{"_account_id":5263,"name":"Jeremy Stanley","display_name":"fungi","email":"fungi@yuggoth.org","username":"fungi","status":"missing, presumed fed"},"change_message_id":"4dd71ee7fe6c828d0b9dd453f9865a4c3ef48aaf","unresolved":false,"context_lines":[{"line_number":46,"context_line":"    timestamp \u003d timestamp[:-3]"},{"line_number":47,"context_line":"    activity \u003d datetime.datetime.strptime(timestamp, TIME_FORMAT)"},{"line_number":48,"context_line":"    now \u003d datetime.datetime.now()"},{"line_number":49,"context_line":"    if now - activity \u003c YEAR_AGO:"},{"line_number":50,"context_line":"        # We decide the account is active if it has reviewed or pushed code"},{"line_number":51,"context_line":"        # within the last year."},{"line_number":52,"context_line":"        return True"}],"source_content_type":"text/x-python","patch_set":1,"id":"25f6fcce_db362da1","line":49,"updated":"2021-02-26 23:29:59.000000000","message":"We can try varying this and see if, e.g., three years significantly increases the number of accounts we need to clean up. There might be a sweet spot where we can consider accounts less recently active without too much extra pain.","commit_id":"c3b972f41a4c228baf34d9ef321b8fac989aa23a"},{"author":{"_account_id":5263,"name":"Jeremy Stanley","display_name":"fungi","email":"fungi@yuggoth.org","username":"fungi","status":"missing, presumed fed"},"change_message_id":"4dd71ee7fe6c828d0b9dd453f9865a4c3ef48aaf","unresolved":false,"context_lines":[{"line_number":62,"context_line":""},{"line_number":63,"context_line":"def get_user_activity(users, auth\u003dNone):"},{"line_number":64,"context_line":"    for email in users.keys():"},{"line_number":65,"context_line":"        query \u003d {\u0027q\u0027: \u0027email:%s (is:active OR is:inactive)\u0027 % email}"},{"line_number":66,"context_line":"        j \u003d query_gerrit(\u0027accounts\u0027, query, auth)"},{"line_number":67,"context_line":"        if len(j) \u003c 2:"},{"line_number":68,"context_line":"            # Using an admin account to query this info seems to address"}],"source_content_type":"text/x-python","patch_set":1,"id":"cc86a3e5_420321a5","line":65,"updated":"2021-02-26 23:29:59.000000000","message":"We should do a pass for is:inactive users with conflicts and just clean them up first. It could significantly reduce the set we need to reason about.","commit_id":"c3b972f41a4c228baf34d9ef321b8fac989aa23a"},{"author":{"_account_id":5263,"name":"Jeremy Stanley","display_name":"fungi","email":"fungi@yuggoth.org","username":"fungi","status":"missing, presumed fed"},"change_message_id":"4dd71ee7fe6c828d0b9dd453f9865a4c3ef48aaf","unresolved":false,"context_lines":[{"line_number":76,"context_line":"            # Gerrit appears to do a reverse sort giving you the newest results"},{"line_number":77,"context_line":"            # first. Since we only care about the most recent activity we set"},{"line_number":78,"context_line":"            # n \u003d 1 here."},{"line_number":79,"context_line":"            query \u003d {\u0027q\u0027: \u0027owner:%s\u0027 % account_id, \u0027n\u0027: 1}"},{"line_number":80,"context_line":"            j \u003d query_gerrit(\u0027changes\u0027, query, auth)"},{"line_number":81,"context_line":"            if j:"},{"line_number":82,"context_line":"                users[email][account_id][\u0027recent_change\u0027] \u003d j[0][\u0027updated\u0027]"}],"source_content_type":"text/x-python","patch_set":1,"id":"f177661a_fa52837b","line":79,"updated":"2021-02-26 23:29:59.000000000","message":"Consider constraining to something like after:YEAR_AGO so that the data returned isn\u0027t greater than necessary. Will speed up the script quite a bit, I expect.","commit_id":"c3b972f41a4c228baf34d9ef321b8fac989aa23a"},{"author":{"_account_id":5263,"name":"Jeremy Stanley","display_name":"fungi","email":"fungi@yuggoth.org","username":"fungi","status":"missing, presumed fed"},"change_message_id":"c327dd146c637466571c17beebe0fb97348c10ad","unresolved":false,"context_lines":[{"line_number":78,"context_line":"    query \u003d {\u0027q\u0027: \u0027owner:%s after:%s\u0027 % (account_id, YEAR_AGO.strftime(\u0027%Y-%m-%d\u0027)), \u0027n\u0027: 1}"},{"line_number":79,"context_line":"    j \u003d query_gerrit(\u0027changes\u0027, query, auth)"},{"line_number":80,"context_line":"    if j:"},{"line_number":81,"context_line":"        account_info[\u0027recent_change\u0027] \u003d j[0][\u0027updated\u0027]"},{"line_number":82,"context_line":"        if recently_used(account_info[\u0027recent_change\u0027]):"},{"line_number":83,"context_line":"            account_info[\u0027recently_used\u0027] \u003d True"},{"line_number":84,"context_line":"    else:"}],"source_content_type":"text/x-python","patch_set":2,"id":"7ec42453_3808ebdc","line":81,"updated":"2021-03-01 22:51:35.000000000","message":"I think you\u0027ll still want to iterate through these. If memory serves, the \"after\" means there was some activity on the change after that time, not that the activity is associated with the specified owner or reviewer.","commit_id":"74e2d9382bb1317c18cef4f280cee3b1e0430fd1"},{"author":{"_account_id":5263,"name":"Jeremy Stanley","display_name":"fungi","email":"fungi@yuggoth.org","username":"fungi","status":"missing, presumed fed"},"change_message_id":"c327dd146c637466571c17beebe0fb97348c10ad","unresolved":false,"context_lines":[{"line_number":87,"context_line":"    query \u003d {\u0027q\u0027: \u0027reviewedby:%s after:%s\u0027 % (account_id, YEAR_AGO.strftime(\u0027%Y-%m-%d\u0027)), \u0027n\u0027: 1}"},{"line_number":88,"context_line":"    j \u003d query_gerrit(\u0027changes\u0027, query, auth)"},{"line_number":89,"context_line":"    if j:"},{"line_number":90,"context_line":"        account_info[\u0027recent_review\u0027] \u003d j[0][\u0027updated\u0027]"},{"line_number":91,"context_line":"        if recently_used(account_info[\u0027recent_review\u0027]):"},{"line_number":92,"context_line":"            account_info[\u0027recently_used\u0027] \u003d True"},{"line_number":93,"context_line":"    else:"}],"source_content_type":"text/x-python","patch_set":2,"id":"dc8a3855_81f00d74","line":90,"updated":"2021-03-01 22:51:35.000000000","message":"Here too. What I do elsewhere (e.g. openstack election tooling) is to go through these until I see a patchset or a comment associated with the account in question, and if so bail early as a success, otherwise you reach the end of the query results and that\u0027s a nonmatch.","commit_id":"74e2d9382bb1317c18cef4f280cee3b1e0430fd1"}],"tools/gerrit-account-inconsistencies/remove-user-external-ids.py":[{"author":{"_account_id":7118,"name":"Ian Wienand","email":"iwienand@redhat.com","username":"iwienand"},"change_message_id":"f02df8b1274a23a698c6f57e447e4d16d078183d","unresolved":true,"context_lines":[{"line_number":20,"context_line":"    return j"},{"line_number":21,"context_line":""},{"line_number":22,"context_line":""},{"line_number":23,"context_line":"def is_active(account_id, auth):"},{"line_number":24,"context_line":"    r \u003d requests.get(\u0027https://review.opendev.org\u0027"},{"line_number":25,"context_line":"                     \u0027/a/accounts/%s/detail\u0027 % account_id,"},{"line_number":26,"context_line":"                     auth\u003dauth)"}],"source_content_type":"text/x-python","patch_set":4,"id":"4bce3eb3_e50909c4","line":23,"updated":"2021-03-02 20:05:50.000000000","message":"it seems there is an end-point \"/active\" that might make this easier?\n\nhttps://review.opendev.org/Documentation/rest-api-accounts.html#get-active","commit_id":"35252268287b224a23fc2a1bb1010da5af009e37"}]}
