no upper limit for number of documents

This commit is contained in:
j 2016-10-27 01:11:42 +02:00
parent db3c235e15
commit 86cccee265

View file

@ -784,7 +784,20 @@ class Client(object):
print(r) print(r)
def _get_documents(self): def _get_documents(self):
files = self.api.findMedia({ query = {
'conditions': [
{'key': 'filename', 'operator': '', 'value': value}
for value in DOCUMENT_FORMATS
],
'operator': '|'
}
n = self.api.findMedia({'query': query})['data']['items']
if n:
o = 0
chunk = 5000
files = []
while o < n:
files += self.api.findMedia({
'query': { 'query': {
'conditions': [ 'conditions': [
{'key': 'filename', 'operator': '', 'value': value} {'key': 'filename', 'operator': '', 'value': value}
@ -793,19 +806,26 @@ class Client(object):
'operator': '|' 'operator': '|'
}, },
'keys': ['item', 'id', 'extension'], 'keys': ['item', 'id', 'extension'],
'range': [0, 5000] 'range': [o, o+chunk]
})['data']['items'] })['data']['items']
d = self.api.findDocuments({ o += chunk
d = []
o = 0
while o < len(files):
d += self.api.findDocuments({
'query': { 'query': {
'conditions': [ 'conditions': [
{'key': 'oshash', 'operator': '==', 'value': f['id']} {'key': 'oshash', 'operator': '==', 'value': f['id']}
for f in files for f in files[o:o+chunk]
], ],
'operator': '|' 'operator': '|'
}, },
'keys': ['id', 'oshash', 'extension'], 'keys': ['id', 'oshash', 'extension'],
'range': [0, len(files)] 'range': [0, chunk]
})['data']['items'] })['data']['items']
o += chunk
else:
d = []
available = set(f['oshash'] available = set(f['oshash']
for f in d if f['extension'] in DOCUMENT_FORMATS) for f in d if f['extension'] in DOCUMENT_FORMATS)
missing = [(f['id'], f['item']) for f in files missing = [(f['id'], f['item']) for f in files