66from src .models .citation import Citation as CitationModel
77from src .services .epmc import EPMCService as EPMCService
88from src .repositories .epmc import EPMCRepo as EPMCRepo
9+ from src .services .grant import GrantService as Grant
10+ from src .config .session import get_session
911
1012
1113router = APIRouter (prefix = "/epmc" , tags = ["Articles" ])
@@ -19,7 +21,7 @@ def __init__(self, epmc_service: EPMCService, db: Session):
1921
2022 def _setup_routes (self ):
2123 @self .router .get ("/epmc/all-articles" , response_model = list [PMCArticleFull ])
22- async def get_all_articles (limit : int = 100 , skip : int = 0 ): # to be fixed
24+ async def get_all_articles (limit : int = 1000 , skip : int = 0 ): # to be fixed
2325 try :
2426 repo = EPMCRepo (self .db )
2527 articles = repo .get_all_articles (limit = limit , skip = skip )
@@ -44,61 +46,61 @@ async def get_all_articles(limit: int = 100, skip: int = 0): # to be fixed
4446 raise HTTPException (status_code = 500 , detail = f"Failed to fetch articles: { str (e )} " )
4547
4648 @self .router .get ("/epmc/all-grants" )
47- async def get_all_grants (limit : int = 100 , skip : int = 0 ):
49+ async def get_all_grants (limit : int = 1000 , skip : int = 0 ):
4850 repo = EPMCRepo (self .db )
4951 service = EPMCService (repo )
5052 return repo .get_all_grants (limit = limit , skip = skip )
5153
5254 @self .router .get ("/epmc/all-pmc-authors" )
53- async def get_all_pmc_authors (limit : int = 100 , skip : int = 0 ):
55+ async def get_all_pmc_authors (limit : int = 1000 , skip : int = 0 ):
5456 repo = EPMCRepo (self .db )
5557 service = EPMCService (repo )
5658 return repo .get_all_pmc_authors (limit = limit , skip = skip )
5759
5860 @self .router .get ("/epmc/get-authors-by-article-id/{article_id}" , response_model = list [PMCAuthor ]) # to be fixed
59- async def get_authors_by_article_id (article_id : int , limit : int = 100 , skip : int = 0 ):
61+ async def get_authors_by_article_id (article_id : int , limit : int = 1000 , skip : int = 0 ):
6062 repo = EPMCRepo (self .db )
6163 service = EPMCService (repo )
6264 return repo .get_authors_by_article_id (article_id , limit = limit , skip = skip )
6365
6466 @self .router .get ("/epmc/get-articles-by-author-id/{author_id}" , response_model = list [PMCArticle ]) # to be fixed
65- async def get_articles_by_author_id (author_id : int , limit : int = 100 , skip : int = 0 ):
67+ async def get_articles_by_author_id (author_id : int , limit : int = 1000 , skip : int = 0 ):
6668 repo = EPMCRepo (self .db )
6769 service = EPMCService (repo )
6870 return repo .get_articles_by_author_id (author_id , limit = limit , skip = skip )
6971
7072 @self .router .get ("/epmc/get-articles-by-keyword/{keyword}" , response_model = list [PMCArticle ]) # to be fixed
71- async def get_articles_by_keyword (keyword : str , limit : int = 100 , skip : int = 0 ):
73+ async def get_articles_by_keyword (keyword : str , limit : int = 1000 , skip : int = 0 ):
7274 repo = EPMCRepo (self .db )
7375 service = EPMCService (repo )
7476 return repo .get_articles_by_keyword (keyword , limit = limit , skip = skip )
7577
7678 @self .router .get ("/epmc/all-article-authors" )
77- async def get_all_article_authors (limit : int = 100 , skip : int = 0 ):
79+ async def get_all_article_authors (limit : int = 1000 , skip : int = 0 ):
7880 repo = EPMCRepo (self .db )
7981 service = EPMCService (repo )
8082 return repo .get_all_article_authors (limit = limit , skip = skip )
8183
8284 @self .router .get ("/epmc/all-pmc-references" )
83- async def get_all_pmc_references (limit : int = 100 , skip : int = 0 ):
85+ async def get_all_pmc_references (limit : int = 1000 , skip : int = 0 ):
8486 repo = EPMCRepo (self .db )
8587 service = EPMCService (repo )
8688 return repo .get_all_pmc_references (limit = limit , skip = skip )
8789
8890 @self .router .get ("/epmc/all-citations" )
89- async def get_all_citations (limit : int = 100 , skip : int = 0 ):
91+ async def get_all_citations (limit : int = 1000 , skip : int = 0 ):
9092 repo = EPMCRepo (self .db )
9193 service = EPMCService (repo )
9294 return repo .get_all_citations (limit = limit , skip = skip )
9395
9496 @self .router .get ("/epmc/all-fulltexts" )
95- async def get_all_fulltexts (limit : int = 100 , skip : int = 0 ):
97+ async def get_all_fulltexts (limit : int = 1000 , skip : int = 0 ):
9698 repo = EPMCRepo (self .db )
9799 service = EPMCService (repo )
98100 return repo .get_all_fulltexts (limit = limit , skip = skip )
99101
100102 @self .router .get ("/epmc/all-pmc-affiliations" )
101- async def get_all_pmc_affiliations (limit : int = 100 , skip : int = 0 ):
103+ async def get_all_pmc_affiliations (limit : int = 1000 , skip : int = 0 ):
102104 repo = EPMCRepo (self .db )
103105 service = EPMCService (repo )
104106 return repo .get_all_pmc_affiliations (limit = limit , skip = skip )
@@ -109,6 +111,11 @@ async def ingest_pmc_data(
109111 ):
110112 repo = EPMCRepo (self .db )
111113 service = EPMCService (repo )
114+ grant_service = Grant (repo )
115+ result = service .insert_articles_by_keyword ("rews" , created_by = "system" , epmc_db = self .db )
116+ citations_result = service .insert_citations (created_by = "system" )
117+ references_result = service .insert_references (created_by = "system" )
118+ grant_result = grant_service .create_grants ("ga4gh" )
112119
113120 try :
114121 service .insert_articles_by_keyword (keyword , created_by = "system" , epmc_db = self .db )
@@ -119,12 +126,12 @@ async def ingest_pmc_data(
119126 return [PMCArticleFull .model_validate (article ) for article in articles ]
120127
121128 @self .router .get ("/epmc/all-latest-entries" )
122- async def get_all_latest_entries (limit : int = 100 , skip : int = 0 ):
129+ async def get_all_latest_entries (limit : int = 1000 , skip : int = 0 ):
123130 repo = EPMCRepo (self .db )
124131 return repo .get_all_latest_entries (limit = limit , skip = skip )
125132
126133 @self .router .get ("/epmc/article/{pm_id}/latest-entries" )
127- async def get_article_latest_entries (pm_id : str , limit : int = 100 , skip : int = 0 ):
134+ async def get_article_latest_entries (pm_id : str , limit : int = 1000 , skip : int = 0 ):
128135 repo = EPMCRepo (self .db )
129136 return repo .get_all_latest_entries (pm_id = pm_id , limit = limit , skip = skip )
130137
@@ -134,7 +141,7 @@ async def get_affiliation_countries_count():
134141 return repo .get_affiliation_countries_count ()
135142
136143 @self .router .get ("/epmc/unique-citations" , response_model = list [CitationModel ])
137- async def get_unique_citations (limit : int = 100 , skip : int = 0 ):
144+ async def get_unique_citations (limit : int = 1000 , skip : int = 0 ):
138145 repo = EPMCRepo (self .db )
139146 citations = repo .get_unique_citations (limit = limit , skip = skip )
140147 return [CitationModel .model_validate (c ) for c in citations ]
0 commit comments