mirror of https://github.com/CIRCL/lookyloo
fix: Speedup sorted cache
parent
da85aa0fb7
commit
06a4c2cc87
|
@ -452,13 +452,25 @@ class Lookyloo():
|
||||||
@property
|
@property
|
||||||
def sorted_cache(self):
|
def sorted_cache(self):
|
||||||
all_cache = []
|
all_cache = []
|
||||||
for capture_uuid in self.capture_uuids:
|
p = self.redis.pipeline()
|
||||||
try:
|
for directory in self.redis.hmget('lookup_dirs', *self.capture_uuids):
|
||||||
cache = self.capture_cache(capture_uuid)
|
if directory:
|
||||||
if cache and 'timestamp' in cache:
|
p.hgetall(directory)
|
||||||
all_cache.append(cache)
|
all_cache = []
|
||||||
except Exception:
|
for c in p.execute():
|
||||||
|
if not c:
|
||||||
|
continue
|
||||||
|
if all(key in c.keys() for key in ['uuid', 'title', 'timestamp', 'url', 'redirects', 'capture_dir']):
|
||||||
|
c['redirects'] = json.loads(c['redirects'])
|
||||||
|
c['capture_dir'] = Path(c['capture_dir'])
|
||||||
|
all_cache.append(c)
|
||||||
|
elif 'error' in c:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
if 'timestamp' not in c:
|
||||||
|
continue
|
||||||
|
all_cache.append(c)
|
||||||
return sorted(all_cache, key=operator.itemgetter('timestamp'), reverse=True)
|
return sorted(all_cache, key=operator.itemgetter('timestamp'), reverse=True)
|
||||||
|
|
||||||
def capture_cache(self, capture_uuid: str) -> Dict[str, Union[str, Path]]:
|
def capture_cache(self, capture_uuid: str) -> Dict[str, Union[str, Path]]:
|
||||||
|
|
Loading…
Reference in New Issue