Commit f5443d84 authored by Mathieu Rodic's avatar Mathieu Rodic

[FEATURE] Added 'authors' metadata support

[ANOMALY] Fixed buggy behaviour of query type 'fields'
parent 8735df68
...@@ -10,10 +10,6 @@ os.environ.setdefault("DJANGO_HSTORE_GLOBAL_REGISTER", "False") ...@@ -10,10 +10,6 @@ os.environ.setdefault("DJANGO_HSTORE_GLOBAL_REGISTER", "False")
from node.models import * from node.models import *
# Node.objects.get(id=26514).children.all().make_metadata_filterable()
# exit()
# Reset: all data # Reset: all data
tables_to_empty = [ tables_to_empty = [
......
...@@ -428,11 +428,11 @@ class NodesChildrenQueries(APIView): ...@@ -428,11 +428,11 @@ class NodesChildrenQueries(APIView):
# TODO: date_trunc (psql) -> index also # TODO: date_trunc (psql) -> index also
# groupping # groupping
authorized_aggregates = {'count': func.count(Node.id)} if retrieve['type'] == 'aggregates':
for field_name in fields_names: authorized_aggregates = {'count': func.count(Node.id)}
if field_name not in authorized_aggregates: for field_name in fields_names:
# query = query.group_by(text(field_name)) if field_name not in authorized_aggregates:
query = query.group_by('"%s"' % (field_name, )) query = query.group_by('"%s"' % (field_name, ))
# sorting # sorting
sort_fields_names = request.DATA.get('sort', ['id']) sort_fields_names = request.DATA.get('sort', ['id'])
......
...@@ -25,13 +25,20 @@ class PubmedFileParser(FileParser): ...@@ -25,13 +25,20 @@ class PubmedFileParser(FileParser):
"publication_year" : 'MedlineCitation/DateCreated/Year', "publication_year" : 'MedlineCitation/DateCreated/Year',
"publication_month" : 'MedlineCitation/DateCreated/Month', "publication_month" : 'MedlineCitation/DateCreated/Month',
"publication_day" : 'MedlineCitation/DateCreated/Day', "publication_day" : 'MedlineCitation/DateCreated/Day',
"authors" : 'MedlineCitation/Article/AuthorList',
} }
for key, path in metadata_path.items(): for key, path in metadata_path.items():
try: try:
node = xml_article.find(path) xml_node = xml_article.find(path)
metadata[key] = node.text if key == 'authors':
metadata[key] = ', '.join([
xml_author.find('ForeName').text + ' ' + xml_author.find('LastName').text
for xml_author in xml_node
])
else:
metadata[key] = xml_node.text
except: except:
metadata[key] = "" pass
metadata_list.append(metadata) metadata_list.append(metadata)
# return the list of metadata # return the list of metadata
return metadata_list return metadata_list
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