Make the iterable parameter optional in get_user_ids_requiring_device_list_resync

pull/7453/head
Brendan Abolivier 2020-05-07 16:49:34 +02:00
parent c06f4934ec
commit 7c6625dc76
No known key found for this signature in database
GPG Key ID: 1E015C145F1916CD
1 changed files with 20 additions and 11 deletions

View File

@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging import logging
from typing import List, Tuple from typing import List, Optional, Tuple, Set
from six import iteritems from six import iteritems
@ -654,21 +654,30 @@ class DeviceWorkerStore(SQLBaseStore):
return results return results
@defer.inlineCallbacks @defer.inlineCallbacks
def get_user_ids_requiring_device_list_resync(self, user_ids: Collection[str]): def get_user_ids_requiring_device_list_resync(
self, user_ids: Optional[Collection[str]] = None,
) -> Set[str]:
"""Given a list of remote users return the list of users that we """Given a list of remote users return the list of users that we
should resync the device lists for. should resync the device lists for.
Returns: Returns:
Deferred[Set[str]] The IDs of users whose device lists need resync.
""" """
if user_ids:
rows = yield self.db.simple_select_many_batch( rows = yield self.db.simple_select_many_batch(
table="device_lists_remote_resync", table="device_lists_remote_resync",
column="user_id", column="user_id",
iterable=user_ids, iterable=user_ids,
retcols=("user_id",), retcols=("user_id",),
desc="get_user_ids_requiring_device_list_resync", desc="get_user_ids_requiring_device_list_resync_with_iterable",
) )
else:
rows = yield self.db.simple_select_list(
table="device_lists_remote_resync",
keyvalues=None,
retcols=("user_id",),
desc="get_user_ids_requiring_device_list_resync"
)
return {row["user_id"] for row in rows} return {row["user_id"] for row in rows}