summaryrefslogtreecommitdiffstats
path: root/scripts/misc.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/misc.py')
-rw-r--r--scripts/misc.py43
1 files changed, 19 insertions, 24 deletions
diff --git a/scripts/misc.py b/scripts/misc.py
index 216998c..564d8d3 100644
--- a/scripts/misc.py
+++ b/scripts/misc.py
@@ -140,35 +140,30 @@ def getAllSnapshots(host_id, platform_id, branch_id, reverse = False):
" WHERE hostId = %d"
" AND platformId = %d"
" AND branchId = %d"
- % (host_id, platform_id, branch_id) +
+ % (host_id, platform_id, branch_id) +
" ORDER BY timestamp " + ("DESC;" if reverse else "ASC;"))
return tuple(snapshots)
-# Gets the (SHA-1 ID, timestamp) pair associated with the most recent rankings
-# computed for the given host/platform/branch combination.
-# The 'snapshots' argument is a chronologically ordered n-tuple of
-# (SHA-1 ID, first upload timestamp) pairs. Returns (-1, -1) if no match
-# is found.
-def getLastRankingSnapshot(host_id, platform_id, branch_id, snapshots):
-
- # Get all SHA-1 IDs in 'ranking' for this host/platform/branch
- # combination:
- ranking_sha1_ids = zip(*execQuery(
- "SELECT DISTINCT sha1Id FROM ranking " +
- "WHERE hostId = " + str(host_id) +
- " AND platformId = " + str(platform_id) +
- " AND branchId = " + str(branch_id) +
- ";"))[0]
-
- # Find the most recent one among the ranking SHA-1 IDs:
- for sha1_id, timestamp in reversed(snapshots):
- print "sha1_id:", sha1_id
- if sha1_id in ranking_sha1_ids:
- return (sha1_id, timestamp)
-
- return (-1, -1) # not found
+# Returns the (SHA-1 ID, timestamp) pair associated with the most recent
+# rankings computed for the given host/platform/branch combination, or
+# (-1, -1) if no match is found.
+def getLastRankingSnapshot(host_id, platform_id, branch_id):
+ result = execQuery(
+ "SELECT matchingcontext.sha1id, timestamp"
+ " FROM ranking,"
+ " (SELECT id, sha1Id, timestamp"
+ " FROM context"
+ " WHERE hostId = %d"
+ " AND platformId = %d"
+ " AND branchId = %d) AS matchingContext"
+ " WHERE contextId = matchingContext.id"
+ " ORDER BY timestamp DESC LIMIT 1;"
+ % (host_id, platform_id, branch_id))
+ if len(result):
+ return query_result[0]
+ return -1, -1
# Retrieves the time series of valid median results for the given