diff --git a/explore/src/app/funders/funders.component.html b/explore/src/app/funders/funders.component.html index 0ee945d6..2b262f89 100644 --- a/explore/src/app/funders/funders.component.html +++ b/explore/src/app/funders/funders.component.html @@ -75,7 +75,7 @@
-
+
@@ -145,10 +145,10 @@
- -
- - {{funder.alias}} + +
+ + {{funder.shortName}}
@@ -243,9 +243,9 @@ {{funder.name}} - + - ({{funder.alias}}) + ({{funder.shortName}})
diff --git a/explore/src/app/funders/funders.component.ts b/explore/src/app/funders/funders.component.ts index 2e0834a8..15a3882b 100644 --- a/explore/src/app/funders/funders.component.ts +++ b/explore/src/app/funders/funders.component.ts @@ -54,6 +54,7 @@ export class FundersComponent implements OnInit { fundersMap = new Map(); staticLogos: Map = new Map([ - ["arc_________::ARC", "ARC"], - ["asap________::ASAP", "ASAP"], - ["cihr________::CIHR", "CIHR"], - ["euenvagency_::EEA", "EEA"], - ["inca________::INCA", "INCa"], - ["nhmrc_______::NHMRC", "NHMRC"], - ["nih_________::NIH", "NIH"], - ["nserc_______::NSERC", "NSERC"], - ["nsf_________::NSF", "NSF"], - ["sshrc_______::SSHRC", "SSHRC"], - ["taraexp_____::tara", "TARA"], - ["ukri________::UKRI", "UKRI"], - ["wt__________::WT", "WT"] + ["arc_________::ARC||Australian Research Council (ARC)||ARC", "ARC"], + ["asap________::ASAP||Aligning Science Across Parkinson's||ASAP", "ASAP"], + ["cihr________::CIHR||Canadian Institutes of Health Research||CIHR", "CIHR"], + ["euenvagency_::EEA||European Environment Agency||EEA", "EEA"], + ["inca________::INCA||Institut National du Cancer||INCa", "INCa"], + ["nhmrc_______::NHMRC||National Health and Medical Research Council (NHMRC)||NHMRC", "NHMRC"], + ["nih_________::NIH||National Institutes of Health||NIH", "NIH"], + ["nserc_______::NSERC||Natural Sciences and Engineering Research Council of Canada||NSERC", "NSERC"], + ["nsf_________::NSF||National Science Foundation||NSF", "NSF"], + ["sshrc_______::SSHRC||Social Sciences and Humanities Research Council||SSHRC", "SSHRC"], + ["taraexp_____::tara||Tara Expeditions Foundation||TARA", "TARA"], + ["ukri________::UKRI||UK Research and Innovation||UKRI", "UKRI"], + ["wt__________::WT||Wellcome Trust||WT", "WT"] ]); constructor(private router: Router, @@ -160,6 +161,7 @@ export class FundersComponent implements OnInit { let funder = { "id": id, "name": this.removePartAfterCharacters(queriedFunder.name, "||"), + "shortName": queriedFunder.shortName, "alias": '', "researchProducts": +queriedFunder.results, "openAccessResearchProducts": +queriedFunder.openResults, @@ -180,6 +182,9 @@ export class FundersComponent implements OnInit { if(queriedFunder.stakeholder) { let stakeholder = queriedFunder.stakeholder; funder.alias = stakeholder.alias; + if(!funder.shortName) { + funder.shortName = stakeholder.alias; + } funder.monitorDashboard = stakeholder.alias; funder.monitorDashboardStatus = stakeholder.visibility; if(stakeholder.logoUrl) { diff --git a/services/cache/mecache/cache.js b/services/cache/mecache/cache.js index 18a34898..ca40b2f3 100644 --- a/services/cache/mecache/cache.js +++ b/services/cache/mecache/cache.js @@ -11,6 +11,7 @@ const PropertiesReader = require('properties-reader'); const properties = PropertiesReader('./properties.file'); const environment = properties.get("environment"); const preloadRequests = properties.get("preloadRequests").split(',');; +var accesslog = require('access-log'); const cacheMaxSize = 1000; let cors = require('cors'); @@ -84,10 +85,11 @@ let cache = () => { } }; - + accesslogCustomFormat(req, res); next(); } } else { + accesslogCustomFormat(req, res); next(); } }; @@ -105,7 +107,7 @@ app.get('/clear', (req, res) => { const url = req.query.url; let message = ""; if (url) { - let key = '__express__' + req.query.url; + let key = req.query.url; lruCache.delete(key); message = "Delete entry with key " + url; entries.set(lruCache.size); @@ -117,15 +119,18 @@ app.get('/clear', (req, res) => { res.header("Access-Control-Allow-Methods", "GET, OPTIONS"); res.header("Access-Control-Allow-Methods", "GET, OPTIONS"); res.header("Content-Type", "application/json"); + accesslogCustomFormat(req, res); res.status(200).send(getResponse(200, message)); }); app.get('/metrics', (req, res) => { res.set('Content-Type', register.contentType); + accesslogCustomFormat(req, res); res.end(register.metrics()); }); app.get('/info', (req, res) => { + accesslogCustomFormat(req, res); res.status(200).send(getResponse(200, {size:lruCache.size, keys: Array.from(lruCache.keys())})); }); @@ -210,3 +215,19 @@ function resetAtMidnight() { resetAtMidnight(); // Then, reset again next midnight. }, msToMidnight); } + +function accesslogCustomFormat(req, res){ + // default format + accesslog(req, res); + // ::ffff:195.134.66.178 - - [15/Jul/2024:11:24:35 +0300] "GET /clear HTTP/1.1" 200 59 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0" + + //custom format + /* + accesslog(req, res, + { + userID: function (req) { return req.user; }, + format : 'url=":url" method=":method" statusCode=":statusCode" delta=":delta" ip=":ip"' + }); + */ +// url="/clear" method="GET" statusCode="200" delta="2" ip="::ffff:195.134.66.178" +} diff --git a/services/cache/mecache/package.json b/services/cache/mecache/package.json index f35341f4..27345f42 100644 --- a/services/cache/mecache/package.json +++ b/services/cache/mecache/package.json @@ -1,6 +1,6 @@ { "name": "memcache-cache", - "version": "1.0.0", + "version": "2.0.0", "description": "Caching in memory", "main": "cache.js", "scripts": { @@ -10,6 +10,7 @@ "prepare-prod": " npm run prepare-dist; cp production-properties.file ./dist/properties.file" }, "dependencies": { + "access-log": "^0.4.1", "axios": "^1.6.7", "compression": "^1.7.4", "cors": "^2.8.5", diff --git a/services/utils-service/uploadService.js b/services/utils-service/uploadService.js index 01919451..a7e67d1c 100644 --- a/services/utils-service/uploadService.js +++ b/services/utils-service/uploadService.js @@ -234,51 +234,79 @@ app.get('/explore/funders', async function (req, res) { let resultsFunders = dataResponses[0].data.refineResults.relfunder; resultsFunders.forEach(queriedFunder => { - let id = queriedFunder.id.split("||")[0]; + let id = queriedFunder.id; + let name = queriedFunder.name.split("||"); if (!fundersMap.has(id)) { - fundersMap.set(id,{name: queriedFunder.name.split("||")[0], id: id, results:queriedFunder.count, openResults: null, projects:null, stakeholder:null}); + fundersMap.set(id,{name: name?.length>0 ? name[0] : "", shortName: name?.length>1 ? name[1] : "", id: id, results:queriedFunder.count, openResults: null, projects:null, stakeholder:null}); } }); let openResultsFunders = dataResponses[1].data.refineResults.relfunder; openResultsFunders.forEach(queriedFunder => { - let id = queriedFunder.id.split("||")[0]; + let id = queriedFunder.id; + let name = queriedFunder.name.split("||"); if (!fundersMap.has(id)) { - fundersMap.set(id,{name: queriedFunder.name.split("||")[0], id: id, results:null, openResults: queriedFunder.count, projects:null, stakeholder:null}); + fundersMap.set(id,{name: name?.length>0 ? name[0] : "", shortName: name?.length>1 ? name[1] : "", id: id, results:null, openResults: queriedFunder.count, projects:null, stakeholder:null}); }else{ fundersMap.get(id).openResults = queriedFunder.count; } }); let projectFunders = dataResponses[2].data.refineResults.funder; projectFunders.forEach(queriedFunder => { - let id = queriedFunder.id.split("||")[0]; + let id = queriedFunder.id; + let name = queriedFunder.name.split("||"); if (!fundersMap.has(id) ) { - fundersMap.set(id,{name: queriedFunder.name.split("||")[0], id: id, results:null, openResults: null, projects:queriedFunder.count, stakeholder:null}); + fundersMap.set(id,{name: name?.length>0 ? name[0] : "", shortName: name?.length>1 ? name[1] : "", id: id, results:null, openResults: null, projects:queriedFunder.count, stakeholder:null}); }else{ 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; - if (fundersMap.has(id)) { - let ministakeholder = {id:id, name:stakeholder.name, alias: stakeholder.alias, visibility: stakeholder.visibility, + let id = stakeholder.index_id + "||" + stakeholder.index_name + "||" + stakeholder.index_shortName; + if (fundersMap.has(id) && (!fundersMap.get(id).stakeholder || (fundersMap.get(id).name === stakeholder.name) || (fundersMap.get(id).shortName === stakeholder.index_shortName))) { + let ministakeholder = { + id:id, name:stakeholder.name, + alias: stakeholder.alias, visibility: stakeholder.visibility, logoUrl:stakeholder.logoUrl, isUpload: stakeholder.isUpload, websiteUrl: null} fundersMap.get(id).stakeholder = ministakeholder; + + if(!fundersMap.get(id).shortName) { + fundersMap.get(id).shortName = stakeholder.index_shortName; + } } }); let funders = dataResponses[4].data; funders.forEach(funder => { - if (fundersMap.has(funder.id)) { - let storedFunder = fundersMap.get(funder.id); + // let id = funder.id + "||" + (funder.legalName ? (funder.legalName + "||" + (funder.legalShortName ? funder.legalShortName : "")) : ""); + // if (fundersMap.has(id)) { + // let storedFunder = fundersMap.get(id); + let storedFunder = null; + fundersMap.forEach((value, key, map) => { + if(key.split("||")[0] === funder.id) { + storedFunder = value; + } + }) + if (storedFunder) { + // if(funder.legalName && storedFunder.name && funder.legalName != storedFunder.name) { + // console.log("Diffrent name!!! index: "+storedFunder.name + " vs funders API: "+funder.legalName); + // } if(funder.legalName) { storedFunder.name = funder.legalName; } storedFunder.country = funder.country; storedFunder.registered = funder.registered; + if(!storedFunder.shortName) { + storedFunder.shortName = funder.legalShortName; + } let storedStakeholder = storedFunder.stakeholder; + + // if(funder.legalShortName && storedFunder.shortName && funder.legalShortName != storedFunder.shortName) { + // console.log("Diffrent short name!!! index: "+storedFunder.shortName + " vs funders API: "+funder.legalShortName); + // } + let ministakeholder = { - id:funder.id, name:storedStakeholder?.name, alias: storedStakeholder?.alias ? storedStakeholder.alias : funder.legalShortName, + id:storedFunder.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 };