diff options
Diffstat (limited to 'scripts/getrankings.py')
-rw-r--r-- | scripts/getrankings.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/scripts/getrankings.py b/scripts/getrankings.py index 02a1f9f..45cc9a3 100644 --- a/scripts/getrankings.py +++ b/scripts/getrankings.py @@ -63,15 +63,15 @@ class GetRankings: # Get all time series notes: qres = execQuery( "SELECT benchmarkId, metricId, note FROM timeSeriesAnnotation" - " WHERE hostId = %d AND platformId = %d AND branchId = %d" - % (self.host_id, self.platform_id, self.branch_id)) + " WHERE hostId = %s AND platformId = %s AND branchId = %s", + (self.host_id, self.platform_id, self.branch_id)) notes = {} for benchmark_id, metric_id, note in qres: notes[benchmark_id, metric_id] = note # Get rankings for each statistic: - stat_infos = execQuery("SELECT id, value FROM rankingStat;") + stat_infos = execQuery("SELECT id, value FROM rankingStat", ()) for stat_id, stat_name in stat_infos: # Get the unsorted ranking information: @@ -79,9 +79,9 @@ class GetRankings: "SELECT benchmarkId, metricId, context1Id, pos, value," " lastChangeTimestamp" " FROM ranking" - " WHERE context2Id = %d" - " AND statId = %d;" - % (self.context2_id, stat_id)) + " WHERE context2Id = %s" + " AND statId = %s", + (self.context2_id, stat_id)) ranking = [] @@ -121,9 +121,9 @@ class GetRankings: ranking_prev_list = execQuery( "SELECT benchmarkId, metricId, pos" " FROM ranking" - " WHERE context2Id = %d" - " AND statId = %d;" - % (context2_prev_id, stat_id)) + " WHERE context2Id = %s" + " AND statId = %s", + (context2_prev_id, stat_id)) ranking_prev = {} for benchmark_id, metric_id, pos in ranking_prev_list: ranking_prev[benchmark_id, metric_id] = pos @@ -152,12 +152,14 @@ class GetRankings: # Extract affected SHA-1s: + assert len(context_ids) > 0 sha1_infos = execQuery( "SELECT context.id, sha1Id, sha1.value" " FROM context, sha1" - " WHERE context.id IN (%s)" - " AND sha1Id = sha1.id;" - % (", ".join(map(str, context_ids)))) + " WHERE context.id IN" + " (%s" + ", %s"*(len(context_ids) - 1) + ")" + + " AND sha1Id = sha1.id", + tuple(context_ids)) return sha1_infos, rankings @@ -191,8 +193,8 @@ class GetRankings: self.sha1_infos, self.rankings = self.getRankings() self.snapshots = self.getSnapshotsInMaxRange(self.sha1_infos) - self.benchmarks = execQuery("SELECT id, value FROM benchmark;") - self.metrics = execQuery("SELECT id, value FROM metric;") + self.benchmarks = execQuery("SELECT id, value FROM benchmark", ()) + self.metrics = execQuery("SELECT id, value FROM metric", ()) self.writeOutput() |