def cache_filler(): from invenio.modules.search.searchext.engines.native import \ search_unit_in_idxphrases collections = Collection.query.all() setattr(get_all_recids, 'cache', dict()) setattr(get_collection_nbrecs, 'cache', dict()) return dict([(c.name, search_unit_in_idxphrases(c.name, 'collection', 'e')) for c in collections])
def cache_filler(): from invenio.modules.search.searchext.engines.native import \ search_unit_in_idxphrases collections = Collection.query.all() setattr(get_all_recids, 'cache', dict()) setattr(get_collection_nbrecs, 'cache', dict()) return dict([ (c.name, search_unit_in_idxphrases(c.name, 'collection', 'e')) for c in collections ])
def get_collection_reclist(coll, recreate_cache_if_needed=True): """Return hitset of recIDs that belong to the collection 'coll'.""" from invenio.modules.search.searchext.engines.native import \ search_unit_in_idxphrases if recreate_cache_if_needed: collection_reclist_cache.recreate_cache_if_needed() if coll not in collection_reclist_cache.cache: return intbitset() if not collection_reclist_cache.cache[coll]: c_coll = Collection.query.filter_by(name=coll).first() if c_coll: collection_reclist_cache.cache[coll] = search_unit_in_idxphrases( c_coll.name, 'collection', 'e') return collection_reclist_cache.cache[coll] or intbitset()