From 0f998d47ee85b33e8c8bd491010e7e485660d7cd Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Tue, 18 Apr 2023 11:00:45 +0200
Subject: [PATCH] Report the number of citations gathered by the papers

---
 query.py            | 7 ++++++-
 templates/pubs.html | 5 ++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/query.py b/query.py
index 0d53efe..a107ab1 100644
--- a/query.py
+++ b/query.py
@@ -4,18 +4,23 @@ import sys
 
 # Query papers citing the two SWIFT ADS entries
 query = ADSQueryWrapper(sys.argv[1])
-query_data = query.get("citations(2016pasc.conf....2S) or citations(2018ascl.soft05020S)", fl="title,bibcode,first_author_norm,date,year,author_count,bibstem,abstract,volume,issue,page", rows=1000)
+query_data = query.get("citations(2016pasc.conf....2S) or citations(2018ascl.soft05020S)", fl="title,bibcode,first_author_norm,date,year,author_count,bibstem,abstract,volume,issue,page,citation_count", rows=1000)
 paper_list = query_data.papers
+total_citations = 0
 
 # Process the data to make the title a string and not an array of strings
 for paper in paper_list:
     paper.title = paper.title[0]
     paper.bibstem = paper.bibstem[0]
+    if hasattr(paper, "page"):
+        paper.page = paper.page[0]
     if hasattr(paper, "abstract"):
         paper.abstract = paper.abstract.replace("<P />", "")
+    total_citations += paper.citation_count
     
 # Create a dictionary of cards
 my_list = dict({"num_papers": query_data.num_found,
+                "total_citations": total_citations,
                 "cards": paper_list})
 
 # Silence the yaml object naming
diff --git a/templates/pubs.html b/templates/pubs.html
index 6376833..f9b1b5a 100644
--- a/templates/pubs.html
+++ b/templates/pubs.html
@@ -25,7 +25,9 @@
         <h2>Publications using SWIFT</h2>
       </div>
       
-      <div> The following {{ num_papers }} publications have made use of SWIFT obtain their results:</div>
+      <div> The following {{ num_papers }} publications have used
+      SWIFT (directly or indirectly) to obtain their results. They
+      have jointly gathered {{ total_citations }} citations.</div>
       
        {% set count  = num_papers %}
       
@@ -47,6 +49,7 @@
 	    {% endif %}
 	  {% endif %}
 	{% endif %}
+	&emsp;&emsp;(citations: {{ card.citation_count }})
 	{% if card.abstract %}
           <p class="hideshow">&emsp; Abstract <i class="fa fa-chevron-right" aria-hidden="true"></i></p> 
           <p class="abstract card">{{ card.abstract }}</p> 
-- 
GitLab