summaryrefslogtreecommitdiffstats
path: root/scripts/settimeseriesnote.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/settimeseriesnote.py')
-rw-r--r--scripts/settimeseriesnote.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/settimeseriesnote.py b/scripts/settimeseriesnote.py
new file mode 100644
index 0000000..7e4aa5b
--- /dev/null
+++ b/scripts/settimeseriesnote.py
@@ -0,0 +1,45 @@
+import sys
+import json
+from dbaccess import execQuery, database, commit
+from misc import textToId, printJSONHeader
+
+class SetTimeSeriesNote:
+
+ def __init__(
+ self, host, platform, branch, benchmark, metric, note):
+ self.host_id = textToId('host', host)
+ self.platform_id = textToId('platform', platform)
+ self.branch_id = textToId('branch', branch)
+ self.benchmark_id = textToId('benchmark', benchmark)
+ self.metric_id = textToId('metric', metric)
+ max_length = 256
+ self.note = note.strip()[:max_length]
+
+ def execute(self):
+
+ if len(self.note) == 0:
+ # Delete the row from the table:
+ query = (
+ "DELETE FROM timeSeriesAnnotation"
+ " WHERE hostId = %d"
+ " AND platformId = %d"
+ " AND branchId = %d"
+ " AND benchmarkId = %d"
+ " AND metricId = %d;"
+ % (self.host_id, self.platform_id, self.branch_id,
+ self.benchmark_id, self.metric_id))
+ execQuery(query, False)
+ else:
+ # Insert or update table row:
+ query = (
+ "SELECT merge_timeSeriesNote(%d, %d, %d, %d, %d, '%s');"
+ % (self.host_id, self.platform_id, self.branch_id,
+ self.benchmark_id, self.metric_id, self.note))
+ execQuery(query, False)
+
+ # Write to database:
+ commit()
+
+ # Return empty reply to client:
+ printJSONHeader()
+ json.dump({ }, sys.stdout)