Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
mrwunderbar666 committed Aug 24, 2022
2 parents 70ca6e3 + 82326ae commit f4fab21
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 43 deletions.
14 changes: 14 additions & 0 deletions flaskinventory/templates/helpers/_viewhelpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ <h2><i class="fas fa-question" alt="Unknown"></i></h2>
{% if publication.published_date %}
<span>({{ publication.published_date.strftime('%Y') }})</span>
{% endif %}
{% for key in publication.keys() %}
{% if '|from' in key %}
<span class="text-muted ms-2">
from: {{ publication.get(key).strftime('%Y-%m-%d') }}
</span>
{%endif%}
{% endfor %}
{% for key in publication.keys() %}
{% if '|to' in key %}
<span class="text-muted ms-1">
to: {{ publication.get(key).strftime('%Y-%m-%d') }}
</span>
{%endif%}
{% endfor %}
</span>
{% if publication.entry_review_status == 'pending' %}
<small data-bs-toggle="tooltip" data-bs-placement="top" title="This entry has to be checked by a reviewer first." class="text-muted">(pending)</small>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<p class="card-text">
<a href="{{ url_for('view.view_generic', dgraph_type='Source', unique_name=source.unique_name) }}">
{{source.name}} ({{source.channel.name}})</a> {% if source.get('sources_included|from') %}
<span class="text-muted mx-3">
<span class="text-muted ms-2">
from: {{ source.get('sources_included|from').strftime('%Y-%m-%d') }}
</span> {%endif%} {% if source.get('sources_included|to') %}
<span class="text-muted mx-3">
<span class="text-muted ms-1">
to: {{ source.get('sources_included|to').strftime('%Y-%m-%d') }}
</span> {%endif%} {% endfor %}
</dd>
Expand Down
30 changes: 6 additions & 24 deletions flaskinventory/templates/view/elements/source/research.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
{% from "helpers/_viewhelpers.html" import render_publication %}
<div class="border rounded p-3">
<dl class="row">
<dt class="col-sm-3 mb-4"><h5>Research</h5></dt>
<dd class="col-sm-9 mb-4"><small class="text-muted">Following publications investigated this source. The date range indicates the sample composition.</small></dd>
<dd class="col-sm-9 mb-4"><small class="text-muted">Following publications investigated this source.</small></dd>
{% if entry.papers %}
<dt class="col-sm-3"></dt>
<dd class="col-sm-9 mb-4">
{% for paper in entry.papers %}
<dt class="col-sm-3">
<em>{{paper.title}} ({{ paper.published_date.strftime('%Y') }})</em>
</dt>
<dd class="col-sm-9 mb-4">
<a href="{{ url_for('view.view_generic', dgraph_type='ResearchPaper', uid=paper.uid) }}">
{% if paper.authors is string %}
{{ paper.authors }}
{% else %}
{{ paper.authors[0] }} {{ 'et al.' if paper.authors|length > 1 else '' }}
{% endif %}
</a>
{% if paper.get('papers|from') %}
<span class="text-muted mx-3">
from: {{ paper.get('papers|from').strftime('%Y-%m-%d') }}
</span>
{%endif%}
{% if paper.get('papers|to') %}
<span class="text-muted mx-1">
to: {{ paper.get('papers|to').strftime('%Y-%m-%d') }}
</span>
{%endif%}
</dd>
<p>{{ render_publication(paper) }}</p>
{% endfor %}
</dd>
{% endif %}
</dl>
</div>
{% from "helpers/_viewhelpers.html" import render_publication %}
<div class="border rounded p-3">
<dl class="row">
<dt class="col-sm-3 mb-4"><h5>Corpora</h5></dt>
Expand Down
34 changes: 17 additions & 17 deletions flaskinventory/view/dgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ def get_entry(unique_name: str = None, uid: str = None, dgraph_type: str = None)
else:
query_func += f'@filter(has(dgraph.type))'

query_fields = '''{ uid dgraph.type expand(_all_) { uid unique_name name entry_review_status user_displayname authors @facets title channel { name unique_name } }'''
query_fields = '''{ uid dgraph.type expand(_all_) (orderasc: unique_name) { uid unique_name name entry_review_status user_displayname authors @facets title channel { name unique_name } }'''

if dgraph_type == 'Source':
query_fields += '''published_by: ~publishes @facets @filter(type("Organization")) { name unique_name uid entry_review_status }
archives: ~sources_included @facets @filter(type("Archive")) { name unique_name uid entry_review_status }
datasets: ~sources_included @facets @filter(type("Dataset")) { name unique_name uid entry_review_status authors @facets }
corpora: ~sources_included @facets @filter(type("Corpus")) { name unique_name uid entry_review_status authors @facets }
papers: ~sources_included @facets @filter(type("ResearchPaper")) { uid title published_date entry_review_status authors @facets }
query_fields += '''published_by: ~publishes @facets @filter(type("Organization")) (orderasc: unique_name) { name unique_name uid entry_review_status }
archives: ~sources_included @facets @filter(type("Archive")) (orderasc: unique_name) { name unique_name uid entry_review_status }
datasets: ~sources_included @facets @filter(type("Dataset")) (orderasc: unique_name) (orderasc: unique_name){ name unique_name uid entry_review_status authors @facets }
corpora: ~sources_included @facets @filter(type("Corpus")) (orderasc: unique_name) { name unique_name uid entry_review_status authors @facets }
papers: ~sources_included @facets @filter(type("ResearchPaper")) (orderasc: published_date) { uid name title published_date entry_review_status authors @facets }
} }'''

elif dgraph_type == 'Organization':
query_fields += 'owned_by: ~owns @filter(type(Organization)) { uid name unique_name entry_review_status } } }'
query_fields += 'owned_by: ~owns @filter(type(Organization)) (orderasc: unique_name) { uid name unique_name entry_review_status } } }'

elif dgraph_type == 'Channel':
query_fields += 'num_sources: count(~channel) } }'
Expand All @@ -56,7 +56,7 @@ def get_entry(unique_name: str = None, uid: str = None, dgraph_type: str = None)
elif dgraph_type == 'Corpus':
query_fields += '''
num_sources: count(sources_included)
papers: ~corpus_used @facets @filter(type("ResearchPaper")) { uid title published_date name entry_review_status authors @facets }
papers: ~corpus_used @facets @filter(type("ResearchPaper")) (orderasc: name) { uid title published_date name entry_review_status authors @facets }
} }
'''

Expand All @@ -78,35 +78,35 @@ def get_entry(unique_name: str = None, uid: str = None, dgraph_type: str = None)

elif dgraph_type == 'Operation':
query_fields += '''
tools: ~used_for @filter(type("Tool")) { uid name unique_name entry_review_status authors @facets published_date programming_languages platform } } }
tools: ~used_for @filter(type("Tool")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date programming_languages platform } } }
'''

elif dgraph_type == 'FileFormat':
query_fields += '''
tools_input: ~input_file_format @filter(type("Tool")) { uid name unique_name entry_review_status authors @facets published_date programming_languages platform }
tools_output: ~output_file_format @filter(type("Tool")) { uid name unique_name entry_review_status authors @facets published_date programming_languages platform }
datasets: ~file_format @filter(type("Dataset")) { uid name unique_name entry_review_status authors @facets published_date }
tools_input: ~input_file_format @filter(type("Tool")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date programming_languages platform }
tools_output: ~output_file_format @filter(type("Tool")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date programming_languages platform }
datasets: ~file_format @filter(type("Dataset")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date }
} }
'''

elif dgraph_type == 'MetaVar':
query_fields += '''
datasets: ~meta_vars @filter(type("Dataset")) { uid name unique_name entry_review_status authors @facets published_date }
corpus: ~meta_vars @filter(type("Corpus")) { uid name unique_name entry_review_status authors @facets published_date }
datasets: ~meta_vars @filter(type("Dataset")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date }
corpus: ~meta_vars @filter(type("Corpus")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date }
} }
'''

elif dgraph_type == 'ConceptVar':
query_fields += '''
datasets: ~concept_vars @filter(type("Dataset")) { uid name unique_name entry_review_status authors @facets published_date }
datasets: ~concept_vars @filter(type("Dataset")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date }
corpus: ~concept_vars @filter(type("Corpus")) { uid name unique_name entry_review_status authors @facets published_date }
tools: ~concept_vars @filter(type("Tool")) { uid name unique_name entry_review_status authors @facets published_date programming_languages platform }
tools: ~concept_vars @filter(type("Tool")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date programming_languages platform }
} }
'''

elif dgraph_type == 'TextUnit':
query_fields += '''
corpus: ~text_units @filter(type("Corpus")) { uid name unique_name entry_review_status authors @facets published_date }
corpus: ~text_units @filter(type("Corpus")) (orderasc: unique_name) { uid name unique_name entry_review_status authors @facets published_date }
} }
'''
else:
Expand Down

0 comments on commit f4fab21

Please sign in to comment.