def ajax_institutions_experiments(): """Datatable handler to get experiments in an institution.""" recid = request.args.get('recid', '') pid = PersistentIdentifier.get('institutions', recid) record = InstitutionsSearch().get_source(pid.object_uuid) try: icn = record.get('ICN', [])[0] except KeyError: icn = '' hits = get_institution_experiments_from_es(icn) return jsonify({ "data": get_institution_experiments_datatables_rows(hits), "total": hits.total })
def ajax_institutions_experiments(): """Datatable handler to get experiments in an institution.""" recid = request.args.get('recid', '') pid = PersistentIdentifier.get('institutions', recid) record = InstitutionsSearch().get_source(pid.object_uuid) try: icn = record.get('ICN', [])[0] except KeyError: icn = '' hits = get_institution_experiments_from_es(icn) return jsonify( { "data": get_institution_experiments_datatables_rows(hits), "total": hits.total } )
def institutions(): """View for institutions collection landing page.""" number_of_records = InstitutionsSearch().count() some_institutions = _get_some_institutions() return render_template( 'inspirehep_theme/search/collection_institutions.html', collection='institutions', number_of_records=number_of_records, result=some_institutions, )
def link_to_hep_affiliation(record): try: icn = record['ICN'] except KeyError: return '' records = InstitutionsSearch().query_from_iq('affiliation:%s' % icn).execute() results = records.hits.total if results: if results == 1: return str(results) + ' Paper from ' + \ str(record['ICN']) else: return str(results) + ' Papers from ' + \ str(record['ICN']) else: return ''
def _get_some_institutions(): some_institutions = InstitutionsSearch().query_from_iq( '' )[:250].execute() return [hit['_source'] for hit in some_institutions.to_dict()['hits']['hits']]