1+ import logging
12import requests
23import pandas as pd
34import json
45import app .constants .api as api_constants
56
7+ logger = logging .getLogger (__name__ )
8+
69
710def get_json (endpoint ):
811 """
912 Generic GET → JSON helper (same as pypi_client.get_json).
1013 """
11- print ( f "Calling API: { endpoint } " )
14+ logger . debug ( "Calling API: %s" , endpoint )
1215 resp = requests .get (endpoint , timeout = 30 )
1316 resp .raise_for_status ()
1417 return resp .json ()
@@ -25,7 +28,7 @@ def get_all_paginated(endpoint, limit=1000):
2528
2629 while True :
2730 params = {"limit" : limit , "skip" : skip }
28- print ( f "Calling API: { endpoint } params={ params } " )
31+ logger . debug ( "Calling API: %s params=%s" , endpoint , params )
2932 resp = requests .get (endpoint , params = params , timeout = 30 )
3033 resp .raise_for_status ()
3134 data = resp .json ()
@@ -187,13 +190,6 @@ def get_affiliations_by_article(pm_id):
187190
188191
189192
190- # ---------------------------------------------------------------------------
191- # Convenience: prepare a DataFrame ready for the layout / callbacks
192- # ---------------------------------------------------------------------------
193-
194- _epmc_cache = {}
195-
196-
197193def _normalize_pub_year (value ):
198194 """Return a 4-digit publication year as int, or None when invalid."""
199195 if value is None :
@@ -210,20 +206,16 @@ def prepare_epmc_data():
210206 """
211207 Fetch and process all EPMC data in a single pass to avoid redundant API calls.
212208 Returns all data needed for the dashboard: DataFrames, counts, and metadata.
213- Results are cached after the first call.
214209
215210 Returns:
216211 tuple: (entries_df, countries_df, authors_df, total_entries, citations,
217212 unique_authors_count, top_authors_data)
218213 """
219- if "result" in _epmc_cache :
220- return _epmc_cache ["result" ]
221214 # Fetch all API data upfront (no redundancy)
222215 raw_entries = get_all_articles (limit = 1000 )
223216 total_entries = len (raw_entries )
224217
225218 raw_countries = get_affiliation_countries_count ()
226- raw_authors = get_all_pmc_authors ()
227219
228220 unique_authors_resp = get_json (api_constants .EPMC_UNIQUE_AUTHOR_COUNT )
229221 unique_authors_count = unique_authors_resp .get ("unique_authors" , 0 ) if isinstance (unique_authors_resp , dict ) else 0
@@ -257,9 +249,8 @@ def prepare_epmc_data():
257249 else :
258250 countries_df = pd .DataFrame ()
259251
260- # Build authors DataFrame
261- authors_df = pd .DataFrame .from_records (raw_authors ) if raw_authors and isinstance (raw_authors , list ) else pd .DataFrame ()
252+ # The current UI uses summary author endpoints and article-specific author lookups,
253+ # so avoid fetching every author row during app startup.
254+ authors_df = pd .DataFrame ()
262255
263- result = (entries_df , countries_df , authors_df , total_entries , citations , unique_authors_count , top_authors_data )
264- _epmc_cache ["result" ] = result
265- return result
256+ return entries_df , countries_df , authors_df , total_entries , citations , unique_authors_count , top_authors_data
0 commit comments