Skip to content
Snippets Groups Projects
Commit 85657eed authored by Erik Johnston's avatar Erik Johnston
Browse files

Bail on where clause instead

parent b48045a8
No related branches found
No related tags found
No related merge requests found
...@@ -90,6 +90,7 @@ class ClientIpStore(background_updates.BackgroundUpdateStore): ...@@ -90,6 +90,7 @@ class ClientIpStore(background_updates.BackgroundUpdateStore):
are (user_id, device_id) tuples. The values are also dicts, with are (user_id, device_id) tuples. The values are also dicts, with
keys giving the column names keys giving the column names
""" """
res = yield self.runInteraction( res = yield self.runInteraction(
"get_last_client_ip_by_device", "get_last_client_ip_by_device",
self._get_last_client_ip_by_device_txn, self._get_last_client_ip_by_device_txn,
...@@ -109,9 +110,6 @@ class ClientIpStore(background_updates.BackgroundUpdateStore): ...@@ -109,9 +110,6 @@ class ClientIpStore(background_updates.BackgroundUpdateStore):
@classmethod @classmethod
def _get_last_client_ip_by_device_txn(cls, txn, devices, retcols): def _get_last_client_ip_by_device_txn(cls, txn, devices, retcols):
if not devices:
return []
where_clauses = [] where_clauses = []
bindings = [] bindings = []
for (user_id, device_id) in devices: for (user_id, device_id) in devices:
...@@ -122,6 +120,9 @@ class ClientIpStore(background_updates.BackgroundUpdateStore): ...@@ -122,6 +120,9 @@ class ClientIpStore(background_updates.BackgroundUpdateStore):
where_clauses.append("(user_id = ? AND device_id = ?)") where_clauses.append("(user_id = ? AND device_id = ?)")
bindings.extend((user_id, device_id)) bindings.extend((user_id, device_id))
if not where_clauses:
return []
inner_select = ( inner_select = (
"SELECT MAX(last_seen) mls, user_id, device_id FROM user_ips " "SELECT MAX(last_seen) mls, user_id, device_id FROM user_ips "
"WHERE %(where)s " "WHERE %(where)s "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment