diff --git a/bin/packages/Correlation.py b/bin/packages/Correlation.py index 5db4805d..bbb33cc6 100755 --- a/bin/packages/Correlation.py +++ b/bin/packages/Correlation.py @@ -132,6 +132,11 @@ class Correlation(object): stop = start + nb_elem -1 return r_serv_metadata.zrange(f'{self.correlation_name}_all:{subtype}', start, stop) + def paginate_list(self, obj_list, nb_elem=50, page=1): + start = (page - 1) * nb_elem + stop = start + nb_elem + return obj_list[start:stop] + def get_all_correlation_types(self): ''' Gel all correlation types diff --git a/tools/extract_cryptocurrency.py b/tools/extract_cryptocurrency.py index 253f55e5..16cd5045 100755 --- a/tools/extract_cryptocurrency.py +++ b/tools/extract_cryptocurrency.py @@ -34,8 +34,6 @@ def sanitise_nb_max_nodes(nb_max_nodes): return nb_max_nodes def get_object_correlation_json(correlation_id, subtype, max_nodes): - max_nodes = sanitise_nb_max_nodes(max_nodes) - object_type = 'cryptocurrency' max_nodes = sanitise_nb_max_nodes(max_nodes) @@ -51,7 +49,8 @@ def get_object_correlation_json(correlation_id, subtype, max_nodes): if __name__ == '__main__': parser = argparse.ArgumentParser(description='Trigger backgroud update') - parser.add_argument('-t', '--type', help='Cryptocurrency type (bitcoin, bitcoin-cash, etherum, litecoin, monero, dash, zcash)', type=str, dest='type', required=True, default=None) + parser.add_argument('-t', '--type', help='Cryptocurrency type (bitcoin, bitcoin-cash, ethereum, litecoin, monero, dash, zcash)', type=str, dest='type', required=True, default=None) + parser.add_argument('-a', '--address', help='Cryptocurrency addresses', type=str, dest='address', required=True, default=None, nargs="*") parser.add_argument('-p', '--page',help='page number' , type=int, default=1, dest='page') parser.add_argument('-n', '--nb',help='number of addresses by page' , type=int, default=50, dest='nb_elem') parser.add_argument('--node' ,help='correlation graph: max number of nodes' , type=int, default=50, dest='max_nodes') @@ -67,7 +66,11 @@ if __name__ == '__main__': max_nodes = sanitise_int(args.max_nodes, 300) dict_json = {} - for address in Cryptocurrency.cryptocurrency.get_all_correlations_by_subtype_pagination(subtype, nb_elem=nb_elem, page=page): + if args.address: + l_addresse = Cryptocurrency.cryptocurrency.paginate_list(args.address, nb_elem=nb_elem, page=page) + else: + l_addresse = Cryptocurrency.cryptocurrency.get_all_correlations_by_subtype_pagination(subtype, nb_elem=nb_elem, page=page) + for address in l_addresse: dict_json[address] = get_object_correlation_json(address, subtype, max_nodes) print(json.dumps(dict_json))