Commit 5c07df95 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Enhanced geometry metrics suppport.

parent 46e9fdef
......@@ -84,10 +84,13 @@ class DomainProviderBase extends React.Component {
tooltip: 'Aggregates the number of single configuration calculations (e.g. total energy calculations) as each entry can contain many calculations.',
renderResultString: count => (<span> with <b>{count.toLocaleString()}</b> single configuration calculation{count === 1 ? '' : 's'}</span>)
},
unique_geometries: {
label: 'Unique geometries',
// The unique_geometries search aggregates unique geometries based on 10^8 hashes.
// This takes to long in elastic search for a reasonable user experience.
// Therefore, we only support geometries without uniqueness check
geometries: {
label: 'Geometries',
shortLabel: 'Geometries',
tooltip: 'Aggregates the number of unique simulated system geometries in all entries.',
tooltip: 'Aggregates the number of simulated system geometries in all entries.',
renderResultString: count => (<span> that simulate <b>{count.toLocaleString()}</b> unique geometrie{count === 1 ? '' : 's'}</span>)
},
datasets: {
......
......@@ -270,6 +270,8 @@ class RepoCalcsResource(Resource):
search_request.totals(metrics_to_use=total_metrics)
search_request.statistic('authors', 1000)
elif len(metrics) > 0:
search_request.totals(metrics_to_use=metrics)
try:
if scroll:
......
......@@ -635,7 +635,7 @@ class SearchRequest:
def _response(self, response, with_hits: bool = False) -> Dict[str, Any]:
"""
Prepares a response object covering the total number of resutls, hits, statistics,
Prepares a response object covering the total number of results, hits, statistics,
and quantities. Other aspects like pagination and scrolling have to be added
elsewhere.
"""
......@@ -657,7 +657,7 @@ class SearchRequest:
agg_name = 'metric:%s' % metric
if agg_name in bucket:
result[metric] = bucket[agg_name]['value']
result.update(code_runs=code_runs)
result.update(code_runs=code_runs)
return result
statistics_results = {
......
......@@ -23,6 +23,7 @@ import datetime
import os.path
from urllib.parse import urlencode
import base64
import itertools
from nomad.app.utils import rfc3339DateTime
from nomad.app.api.auth import generate_upload_token
......@@ -873,9 +874,12 @@ class TestRepo():
rv = api.get('/repo/?owner=admin')
assert rv.status_code == 401
@pytest.mark.parametrize('metrics', metrics_permutations)
def test_search_total_metrics(self, api, example_elastic_calcs, no_warn, metrics):
rv = api.get('/repo/?%s' % urlencode(dict(metrics=metrics, statistics=True, datasets=True, uploads=True), doseq=True))
@pytest.mark.parametrize('metrics, statistics', itertools.product(metrics_permutations, [True, False]))
def test_search_total_metrics(self, api, example_elastic_calcs, no_warn, metrics, statistics):
query_params = dict(metrics=metrics)
if statistics:
query_params['statistics'] = True
rv = api.get('/repo/?%s' % urlencode(query_params, doseq=True))
assert rv.status_code == 200, str(rv.data)
data = json.loads(rv.data)
total_metrics = data.get('statistics', {}).get('total', {}).get('all', None)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment