def publish_resource(resource_id, version): resource = resourcemgr.get_resource(resource_id, version=version) if resource.active: click.echo("Resource already published") else: indexmgr.publish_index(resource_id, version=version) click.echo( "Successfully indexed and published all data in {resource_id}, version {version}".format( resource_id=resource_id, version=version ) )
def reindex_resource(resource_id): try: resource = resourcemgr.get_resource(resource_id) indexmgr.publish_index(resource_id) click.echo( "Successfully reindexed all data in {resource_id}, version {version}".format( resource_id=resource_id, version=resource.version ) ) except ResourceNotFoundError: click.echo( "No active version of {resource_id}".format(resource_id=resource_id) )
def fun(**kwargs): app = next(app_f_scope_module(**kwargs)) with app.app_context(): for file in [ "tests/data/config/places.json", "tests/data/config/municipalities.json", ]: with open(file) as fp: resource, version = resourcemgr.create_new_resource_from_file(fp) resourcemgr.setup_resource_class(resource, version) if kwargs.get("use_elasticsearch", False): indexmgr.publish_index(resource, version) return app