findmissing: restore should set status to open if changeid created

This fixes the issue with the following scenario:

robot creates a fix_patch where it intially conflicts.
robot later determined fix_patch applies cleanly and creates the CL
(marks its current status as OPEN)
row is later abandoned.
row is later reopened but has status CONF which is incorrect.

BUG=None
TEST=None

Change-Id: I1fe219314b4d1a640ba56799a58ccc43b929e44c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2146032
Commit-Queue: Hirthanan Subenderan <hirthanan@google.com>
Tested-by: Hirthanan Subenderan <hirthanan@google.com>
Reviewed-by: Curtis Malainey <cujomalainey@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
diff --git a/contrib/findmissing/cloudsql_interface.py b/contrib/findmissing/cloudsql_interface.py
index 389692a..c181e54 100755
--- a/contrib/findmissing/cloudsql_interface.py
+++ b/contrib/findmissing/cloudsql_interface.py
@@ -61,7 +61,7 @@
 def update_change_restored(db, fixes_table, kernel_sha, fixedby_upstream_sha):
     """Updates fixes_table unique fix row to indicate fix cl has been reopened."""
     row = get_fix_status_and_changeid(db, fixes_table, kernel_sha, fixedby_upstream_sha)
-    initial_status = row['initial_status']
+    status = 'OPEN' if row['fix_change_id'] else row['initial_status']
 
     c = db.cursor()
     q = """UPDATE {fixes_table}
@@ -70,7 +70,7 @@
             AND fixedby_upstream_sha = %s
             AND status = 'ABANDONED'""".format(fixes_table=fixes_table)
     close_time = None
-    c.execute(q, [initial_status, close_time, kernel_sha, fixedby_upstream_sha])
+    c.execute(q, [status, close_time, kernel_sha, fixedby_upstream_sha])
     db.commit()