From 59546479fe775861e4d6f401b7289380b42a1e38 Mon Sep 17 00:00:00 2001 From: "anodelman%mozilla.com" Date: Thu, 5 Jun 2008 21:04:28 +0000 Subject: [PATCH] Bug 388658 - graph server should handle duplicate data better p=anodelman r=morgamic git-svn-id: svn://10.0.0.236/trunk@252133 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/new-graph/bulk.cgi | 26 +++++++++++++++++++++++++- mozilla/webtools/new-graph/collect.cgi | 24 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/mozilla/webtools/new-graph/bulk.cgi b/mozilla/webtools/new-graph/bulk.cgi index 62a8ca2101a..74422d49fdb 100755 --- a/mozilla/webtools/new-graph/bulk.cgi +++ b/mozilla/webtools/new-graph/bulk.cgi @@ -74,7 +74,7 @@ if form.has_key("filename"): line = line.rstrip("\n\r") contents = line.split(',') #clear any previous content in the fields variables - stops reuse of data over lines - for field in fields: + for field in fields: globals()[field] = '' if len(contents) < 7: print "Incompatable file format" @@ -127,6 +127,30 @@ if form.has_key("filename"): else: setid = res[0][0] + #determine if we've seen this set of data before + if (type == "discrete" and int(timeval) == 0): + cur = db.cursor() + cur.execute("SELECT dataset_id FROM dataset_values WHERE dataset_id = ? AND time = ?", (setid, timeval)) + res = cur.fetchall() + cur.close + if len(res) <> 0: + print "found a matching discrete data set" + db.execute("DELETE FROM dataset_values WHERE dataset_id = ?", (setid,)) + db.execute("DELETE FROM dataset_branchinfo WHERE dataset_id = ?", (setid,)) + db.execute("DELETE FROM dataset_extra_data WHERE dataset_id = ?", (setid,)) + db.execute("DELETE FROM annotations WHERE dataset_id = ?", (setid,)) + elif (type == "continuous"): + cur = db.cursor() + cur.execute("SELECT dataset_id FROM dataset_values WHERE dataset_id = ? AND time = ?", (setid, timeval)) + res = cur.fetchall() + cur.close + if len(res) <> 0: + print "found a matching continuous data point" + db.execute("DELETE FROM dataset_values WHERE dataset_id = ? AND time = ?", (setid, timeval)) + db.execute("DELETE FROM dataset_branchinfo WHERE dataset_id = ? AND time = ?", (setid, timeval)) + db.execute("DELETE FROM dataset_extra_data WHERE dataset_id = ? AND time = ?", (setid, timeval)) + db.execute("DELETE FROM annotations WHERE dataset_id = ? AND time = ?", (setid, timeval)) + db.execute("INSERT INTO dataset_values (dataset_id, time, value) VALUES (?,?,?)", (setid, timeval, value)) db.execute("INSERT INTO dataset_branchinfo (dataset_id, time, branchid) VALUES (?,?,?)", (setid, timeval, branchid)) if data and data != "": diff --git a/mozilla/webtools/new-graph/collect.cgi b/mozilla/webtools/new-graph/collect.cgi index b09d934e811..5aa7baaab25 100755 --- a/mozilla/webtools/new-graph/collect.cgi +++ b/mozilla/webtools/new-graph/collect.cgi @@ -104,6 +104,30 @@ while setid == -1: else: setid = res[0][0] +#determine if we've seen this set of data before +if (type == "discrete" and int(timeval) == 0): + cur = db.cursor() + cur.execute("SELECT dataset_id FROM dataset_values WHERE dataset_id = ? AND time = ?", (setid, timeval)) + res = cur.fetchall() + cur.close + if len(res) <> 0: + print "found a matching discrete data set" + db.execute("DELETE FROM dataset_values WHERE dataset_id = ?", (setid,)) + db.execute("DELETE FROM dataset_branchinfo WHERE dataset_id = ?", (setid,)) + db.execute("DELETE FROM dataset_extra_data WHERE dataset_id = ?", (setid,)) + db.execute("DELETE FROM annotations WHERE dataset_id = ?", (setid,)) +elif (type == "continuous"): + cur = db.cursor() + cur.execute("SELECT dataset_id FROM dataset_values WHERE dataset_id = ? AND time = ?", (setid, timeval)) + res = cur.fetchall() + cur.close + if len(res) <> 0: + print "found a matching continuous data point" + db.execute("DELETE FROM dataset_values WHERE dataset_id = ? AND time = ?", (setid, timeval)) + db.execute("DELETE FROM dataset_branchinfo WHERE dataset_id = ? AND time = ?", (setid, timeval)) + db.execute("DELETE FROM dataset_extra_data WHERE dataset_id = ? AND time = ?", (setid, timeval)) + db.execute("DELETE FROM annotations WHERE dataset_id = ? AND time = ?", (setid, timeval)) + db.execute("INSERT INTO dataset_values (dataset_id, time, value) VALUES (?,?,?)", (setid, timeval, value)) db.execute("INSERT INTO dataset_branchinfo (dataset_id, time, branchid) VALUES (?,?,?)", (setid, timeval, branchid)) if data and data != "":