[develop | DONE | CHANGED]: utils-service: beta-properties.file & production-properties.file & properties.file: Added property fundersServiceAPIUrl | uploadService.js: Added query and parsing of funders from new Funders API (created by CNR) for extra info (country, websiteUrl, registered, etc..)
This commit is contained in:
parent
24696d7991
commit
1494f44362
|
@ -1,6 +1,7 @@
|
|||
userInfoUrl = https://beta.services.openaire.eu/login-service/userInfo
|
||||
searchServiceAPIUrl = https://beta.services.openaire.eu/search/v2/api/
|
||||
monitorAPIUrl = https://beta.services.openaire.eu/uoa-monitor-service/
|
||||
fundersServiceAPIUrl = https://beta.services.openaire.eu/openaire/funders/
|
||||
ssl = true
|
||||
localPath = false
|
||||
# photo size in KB
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
userInfoUrl = https://services.openaire.eu/login-service/userInfo
|
||||
searchServiceAPIUrl = https://services.openaire.eu/search/v2/api/
|
||||
monitorAPIUrl = https://services.openaire.eu/uoa-monitor-service/
|
||||
fundersServiceAPIUrl = https://services.openaire.eu/openaire/funders/
|
||||
ssl = true
|
||||
localPath = false
|
||||
# photo size in KB
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
userInfoUrl = http://mpagasas.di.uoa.gr:19080/login-service/userInfo
|
||||
searchServiceAPIUrl = https://beta.services.openaire.eu/search/v2/api/
|
||||
monitorAPIUrl = http://duffy.di.uoa.gr:19380/uoa-monitor-service/
|
||||
fundersServiceAPIUrl = https://beta.services.openaire.eu/openaire/funders/
|
||||
ssl = false
|
||||
localPath = true
|
||||
# photo size in KB
|
||||
|
|
|
@ -15,6 +15,7 @@ if (properties.get('ssl')) {
|
|||
}
|
||||
var searchServiceAPIUrl = properties.get('searchServiceAPIUrl');
|
||||
var monitorServiceAPIUrl = properties.get('monitorAPIUrl');
|
||||
var fundersServiceAPIUrl = properties.get('fundersServiceAPIUrl');
|
||||
var auth = properties.get('userInfoUrl');
|
||||
/** @deprecated*/
|
||||
var authDeprecated = auth.includes("accessToken");
|
||||
|
@ -223,7 +224,7 @@ app.get('/explore/funders', async function (req, res) {
|
|||
searchServiceAPIUrl + 'resources2/?format=json&type=results&fq=relfunder=*&refine=true&fields=relfunder&sf=relfunder&page=0&size=0&fq=resultbestaccessright%20exact%20%22Open%20Access%22',
|
||||
searchServiceAPIUrl + 'resources2/?format=json&type=projects&fq=funder=*&fq=projectcode<>"unidentified"&refine=true&fields=funder&sf=funder&page=0&size=0',
|
||||
monitorServiceAPIUrl + 'stakeholder?type=funder',
|
||||
|
||||
fundersServiceAPIUrl
|
||||
]
|
||||
const dataPromises = requests.map((url) => axios.get( url));
|
||||
const dataResponses = await Promise.all(dataPromises);
|
||||
|
@ -233,37 +234,67 @@ app.get('/explore/funders', async function (req, res) {
|
|||
|
||||
let resultsFunders = dataResponses[0].data.refineResults.relfunder;
|
||||
resultsFunders.forEach(queriedFunder => {
|
||||
if (!fundersMap.has(queriedFunder.id)) {
|
||||
fundersMap.set(queriedFunder.id,{name: queriedFunder.name.split("||")[0], id: queriedFunder.id, results:queriedFunder.count, openResults: null, projects:null, stakeholder:null});
|
||||
let id = queriedFunder.id.split("||")[0];
|
||||
if (!fundersMap.has(id)) {
|
||||
fundersMap.set(id,{name: queriedFunder.name.split("||")[0], id: id, results:queriedFunder.count, openResults: null, projects:null, stakeholder:null});
|
||||
}
|
||||
});
|
||||
let openResultsFunders = dataResponses[1].data.refineResults.relfunder;
|
||||
openResultsFunders.forEach(queriedFunder => {
|
||||
if (!fundersMap.has(queriedFunder.id)) {
|
||||
fundersMap.set(queriedFunder.id,{name: queriedFunder.name.split("||")[0], id: queriedFunder.id, results:null, openResults: queriedFunder.count, projects:null, stakeholder:null});
|
||||
let id = queriedFunder.id.split("||")[0];
|
||||
if (!fundersMap.has(id)) {
|
||||
fundersMap.set(id,{name: queriedFunder.name.split("||")[0], id: id, results:null, openResults: queriedFunder.count, projects:null, stakeholder:null});
|
||||
}else{
|
||||
fundersMap.get(queriedFunder.id).openResults = queriedFunder.count;
|
||||
fundersMap.get(id).openResults = queriedFunder.count;
|
||||
}
|
||||
});
|
||||
let projectFunders = dataResponses[2].data.refineResults.funder;
|
||||
projectFunders.forEach(queriedFunder => {
|
||||
if (!fundersMap.has(queriedFunder.id) ) {
|
||||
fundersMap.set(queriedFunder.id,{name: queriedFunder.name.split("||")[0], id: queriedFunder.id, results:null, openResults: null, projects:queriedFunder.count, stakeholder:null});
|
||||
let id = queriedFunder.id.split("||")[0];
|
||||
if (!fundersMap.has(id) ) {
|
||||
fundersMap.set(id,{name: queriedFunder.name.split("||")[0], id: id, results:null, openResults: null, projects:queriedFunder.count, stakeholder:null});
|
||||
}else{
|
||||
fundersMap.get(queriedFunder.id).projects = queriedFunder.count;
|
||||
fundersMap.get(id).projects = queriedFunder.count;
|
||||
}
|
||||
});
|
||||
let stakeholders = dataResponses[3].data;
|
||||
stakeholders.forEach(stakeholder => {
|
||||
let id = stakeholder.index_id + "||" + stakeholder.index_name + "||" + stakeholder.index_shortName;
|
||||
// console.log(id);
|
||||
let id = stakeholder.index_id;// + "||" + stakeholder.index_name + "||" + stakeholder.index_shortName;
|
||||
if (fundersMap.has(id)) {
|
||||
let ministakeholder = {id:id, name:stakeholder.name, alias: stakeholder.alias, visibility: stakeholder.visibility,
|
||||
logoUrl:stakeholder.logoUrl, isUpload: stakeholder.isUpload}
|
||||
logoUrl:stakeholder.logoUrl, isUpload: stakeholder.isUpload, websiteUrl: null}
|
||||
fundersMap.get(id).stakeholder = ministakeholder;
|
||||
}
|
||||
});
|
||||
|
||||
let funders = dataResponses[4].data;
|
||||
funders.forEach(funder => {
|
||||
if (fundersMap.has(funder.id)) {
|
||||
let storedFunder = fundersMap.get(funder.id);
|
||||
if(funder.legalName) {
|
||||
storedFunder.name = funder.legalName;
|
||||
}
|
||||
storedFunder.country = funder.country;
|
||||
storedFunder.registered = funder.registered;
|
||||
let storedStakeholder = storedFunder.stakeholder;
|
||||
let ministakeholder = {
|
||||
id:funder.id, name:storedStakeholder?.name, alias: storedStakeholder?.alias ? storedStakeholder.alias : funder.legalShortName,
|
||||
websiteUrl: funder.websiteUrl, logoUrl: storedStakeholder?.logoUrl ? storedStakeholder.logoUrl : funder.logoUrl,
|
||||
visibility: storedStakeholder?.visibility, isUpload: storedStakeholder?.isUpload
|
||||
};
|
||||
storedFunder.stakeholder = ministakeholder;
|
||||
// } else {
|
||||
// console.log(funder.id);
|
||||
}
|
||||
});
|
||||
|
||||
// console.log("")
|
||||
// for(let f of fundersMap.keys()) {
|
||||
// if(!fundersMap.get(f).stakeholder || (!fundersMap.get(f).stakeholder.websiteUrl && !fundersMap.get(f).country && !fundersMap.get(f).registered)) {
|
||||
// console.log(f);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Combine the data
|
||||
|
||||
// Send the aggregated data as the response
|
||||
|
|
Loading…
Reference in New Issue