diff --git a/protoguide-backend/routes/dblp/keywordPerYear.js b/protoguide-backend/routes/dblp/keywordPerYear.js index 097909e..afb0101 100644 --- a/protoguide-backend/routes/dblp/keywordPerYear.js +++ b/protoguide-backend/routes/dblp/keywordPerYear.js @@ -1,7 +1,6 @@ var express = require('express'); var router = express.Router(); let elasticClient = require('../../util/elastic'); -let buckets = require('../../util/bucket'); router.get('/', function (req, res, next) { @@ -9,6 +8,9 @@ router.get('/', function (req, res, next) { let lte = req.query["l"]; let query = req.query["q"]; + let minYear = 2010; + let maxYear = 2019; + query = query.toLowerCase().split(" ").join(" AND "); let bodyTotalCount = { @@ -75,30 +77,50 @@ router.get('/', function (req, res, next) { } }; + var bundle = [] + elasticClient.search({index: "dblp_pub", body: body}) .then(function (response) { let docs = response.aggregations.groupByYear.buckets; - let bucketSample = buckets; - bucketSample.forEach(function (bucket) { + console.log(JSON.stringify(docs)); + for (let i = minYear; i <= maxYear; i++) { + let data = {}; + let found = false; docs.forEach(function (doc) { - if (bucket.key == doc.key) { - bucket.doc_count = doc.doc_count; + if (i === parseInt(doc.key)) { + found = true; + data = { + "key": i, + "doc_abs": doc.doc_count, + "doc_count": 0 + } } }); - }); + if (!found) { + data = { + "key": i, + "doc_abs": 0, + "doc_count": 0 + } + } + bundle.push(data); + } + console.log(JSON.stringify(bundle)); elasticClient.search({index: "dblp_pub", body: bodyTotalCount}) .then(function (response) { - totalYearlyCountArray = response.aggregations.groupByYear.buckets; - totalYearlyCountArray.forEach(function (record) { - bucketSample.forEach(function (bucket) { - if (bucket.key == record.key) { - bucket.doc_count = (bucket.doc_count / record.doc_count).toFixed(4) * 100; - } - }); - //let docIndex = bucketSample.findIndex(item => item.key === record.key); - //bucketSample[docIndex].doc_count = (bucketSample[docIndex].doc_count / record.doc_count).toFixed(4)*100; + let totalYearlyCountArray = response.aggregations.groupByYear.buckets; + console.log(JSON.stringify(totalYearlyCountArray)) + bundle.forEach(function (data) { + if (data.doc_abs > 0) { + totalYearlyCountArray.forEach(function (record) { + if (parseInt(record.key) === data.key) { + data.doc_count = (data.doc_abs / record.doc_count).toFixed(4) * 100; + } + }) + } }); - res.send(bucketSample); + console.log(JSON.stringify(bundle)); + res.send(bundle); }) .catch(err => { console.log(err); @@ -110,6 +132,8 @@ router.get('/', function (req, res, next) { console.log("returning empty object"); res.send([]); }) + + }); diff --git a/protoguide-backend/routes/due/keywordPerYear.js b/protoguide-backend/routes/due/keywordPerYear.js index c54203c..20701d7 100644 --- a/protoguide-backend/routes/due/keywordPerYear.js +++ b/protoguide-backend/routes/due/keywordPerYear.js @@ -1,7 +1,6 @@ var express = require('express'); var router = express.Router(); let elasticClient = require('../../util/elastic'); -let buckets = require('../../util/bucket'); router.get('/', function (req, res, next) { @@ -10,6 +9,9 @@ router.get('/', function (req, res, next) { let lte = req.query["l"]; let query = req.query["q"]; + let minYear = 2010; + let maxYear = 2019; + query = query.toLowerCase().split(" ").join(" AND "); @@ -77,31 +79,47 @@ router.get('/', function (req, res, next) { } }; + + var bundle = []; + elasticClient.search({index: "publications_ude", body: body}) .then(function (response) { let docs = response.aggregations.groupByYear.buckets; - let bucketSample = buckets; - bucketSample.forEach(function (bucket) { + for (let i = minYear; i <= maxYear; i++) { + let data = {}; + let found = false; docs.forEach(function (doc) { - if (bucket.key === doc.key) { - bucket.doc_count = doc.doc_count; + if (i === doc.key) { + found = true; + data = { + "key": i, + "doc_abs": doc.doc_count, + "doc_count": 0 + } } }); - }); - + if (!found) { + data = { + "key": i, + "doc_abs": 0, + "doc_count": 0 + } + } + bundle.push(data); + } elasticClient.search({index: "publications_ude", body: bodyTotalCount}) .then(function (response) { - totalYearlyCountArray = response.aggregations.groupByYear.buckets; - totalYearlyCountArray.forEach(function (record) { - bucketSample.forEach(function (bucket) { - if (bucket.key === record.key) { - bucket.doc_count = (bucket.doc_count / record.doc_count).toFixed(4) * 100; - } - }); - //let docIndex = bucketSample.findIndex(item => item.key === record.key); - //bucketSample[docIndex].doc_count = (bucketSample[docIndex].doc_count / record.doc_count).toFixed(4)* 100; + let totalYearlyCountArray = response.aggregations.groupByYear.buckets; + bundle.forEach(function (data) { + if (data.doc_abs > 0) { + totalYearlyCountArray.forEach(function (record) { + if (record.key === data.key) { + data.doc_count = (data.doc_abs / record.doc_count).toFixed(4) * 100; + } + }) + } }); - res.send(bucketSample); + res.send(bundle); }) .catch(err => { console.log(err); @@ -114,7 +132,8 @@ router.get('/', function (req, res, next) { console.log("returning empty object"); res.send([]); }) + + }); - module.exports = router; diff --git a/protoguide-backend/util/bucket.js b/protoguide-backend/util/bucket.js deleted file mode 100644 index cec967f..0000000 --- a/protoguide-backend/util/bucket.js +++ /dev/null @@ -1,45 +0,0 @@ -let bucket = [ - { - "key": 2010, - "doc_count": 0, - }, - { - "key": 2011, - "doc_count": 0, - }, - { - "key": 2012, - "doc_count": 0, - }, - { - "key": 2013, - "doc_count": 0, - }, - { - "key": 2014, - "doc_count": 0, - }, - { - "key": 2015, - "doc_count": 0, - }, - { - "key": 2016, - "doc_count": 0, - }, - { - "key": 2017, - "doc_count": 0, - }, - { - "key": 2018, - "doc_count": 0, - }, - { - "key": 2019, - "doc_count": 0, - } - -]; - -module.exports = bucket; \ No newline at end of file diff --git a/protoguide-backend/util/keywords.js b/protoguide-backend/util/keywords.js index adf716c..4519ddd 100644 --- a/protoguide-backend/util/keywords.js +++ b/protoguide-backend/util/keywords.js @@ -1,79 +1,148 @@ let keywords = [ { - "id": 2, - "name": "Artificial intelligence", + "id": 1, + "name": "Computer Science", "children": [ { - "id": 3, - "name": "Neural network", + "id": 2, + "name": "Artificial intelligence", "children": [ { - "id": 35, - "name": "Convolutional Neural Network" + "id": 3, + "name": "Neural network", + "children": [ + { + "id": 35, + "name": "Convolutional Neural Network" + } + ] + }, + { + "id": 4, + "name": "machine learning" + } + ], + }, + { + "id": 5, + "name": "network", + "children": [ + { + "id": 6, + "name": "Network algorithms" + }, + { + "id": 7, + "name": "Wireless networks" + }, + { + "id": 8, + "name": "Cloud computing" } ] }, { - "id": 4, - "name": "machine learning" + "id": 9, + "name": "Security", + "children": [ + { + "id": 10, + "name": "User privacy", + }, + { + "id": 11, + "name": "Cryptography" + }, + { + "id": 12, + "name": "Network security" + } + ] + }, + { + "id": 13, + "name": "Information systems", + "children": [ + { + "id": 14, + "name": "Word wide web" + } + ] + }, + { + "id": 15, + "name": "Computer graphics", + "children": [ + { + "id": 16, + "name": "Rendering" + } + ] } ], }, { - "id": 5, - "name": "network", + "id": 17, + "name": "Chemistry", "children": [ { - "id": 6, - "name": "Network algorithms" + "id": 18, + "name": "Biochemistry", + "children": [ + { + "id": 19, + "name": "Computational Biology" + } + ] }, { - "id": 7, - "name": "Wireless networks" - }, - { - "id": 8, - "name": "Cloud computing" + "id": 20, + "name": "Organometallic chemistry", + "children": [ + { + "id": 21, + "name": "Organometallics for Green Catalysis" + } + ] } ] }, { - "id": 9, - "name": "Security", + "id": 22, + "name": "Medicine", "children": [ { - "id": 10, - "name": "User privacy", + "id": 23, + "name": "Microbiology", + "children": [ + { + "id": 24, + "name": "Fungal physiology" + } + ] }, { - "id": 11, - "name": "Cryptography" + "id": 25, + "name": "Cardiac cardiovascular systems", + "children": [ + { + "id": 26, + "name": "Hypertension" + } + ] }, { - "id": 12, - "name": "Network security" + "id": 27, + "name": "Neuroscience", + "children": [ + { + "id": 28, + "name": "Chronic Fatigue Syndrome" + } + ] } ] }, - { - "id": 13, - "name": "Information systems", - "children": [ - { - "id": 14, - "name": "Word wide web" - } - ] - }, - { - "id": 15, - "name": "Computer graphics", - "children": [ - { - "id": 16, - "name": "Rendering" - } - ] - } + ]; module.exports = keywords; \ No newline at end of file diff --git a/protoguide-frontend/src/components/ComparisonAreaChartComponent.vue b/protoguide-frontend/src/components/ComparisonAreaChartComponent.vue index 48890c9..a74723c 100644 --- a/protoguide-frontend/src/components/ComparisonAreaChartComponent.vue +++ b/protoguide-frontend/src/components/ComparisonAreaChartComponent.vue @@ -25,6 +25,14 @@ { name: "DBLP Entries(%)", data: this.dblp_data.map(x => x.doc_count) + }, + { + name: "DUE Absolute Values", + data: this.due_data.map(x => x.doc_abs) + }, + { + name: "DBLP Absolute Values", + data: this.dblp_data.map(x => x.doc_abs) } ]; }, @@ -44,12 +52,12 @@ stroke: { curve: 'smooth' }, - colors: ['#EE7C34','#0D3E85'], - labels:this.due_data.map(x => x.key), + colors: ['#EE7C34', '#0D3E85', 'rgba(255,255,255,0)', 'rgba(255,255,255,0)'], + labels: this.due_data.map(x => x.key), xaxis: { type: 'String', labels: { - show:false, + show: false, rotate: -90, rotateAlways: false, minHeight: 0, @@ -64,8 +72,37 @@ text: "Percent of entries (%)" }, decimalsInFloat: 2, + floating: false, + seriesName: "DUE Entries(%)" + }, + { + opposite: false, + title: { + text: "Percent of entries (%)" + }, + seriesName: "DUE Entries(%)", + show: false, + decimalsInFloat: 2, floating: false }, + { + opposite: true, + title: { + text: "ABS DUE" + }, + decimalsInFloat: 0, + show: false, + floating: false + }, + { + opposite: true, + title: { + text: "ABS DBLP" + }, + decimalsInFloat: 0, + show: false, + floating: false + } /*{ title: { text: "DUE Entries (%)" @@ -81,7 +118,11 @@ ], legend: { - horizontalAlign: 'left' + horizontalAlign: 'left', + labels: { + colors: undefined, + useSeriesColors: true + }, }, responsive:[{ breakpoint: 480, diff --git a/protoguide-frontend/src/main.js b/protoguide-frontend/src/main.js index d8f2624..3853995 100644 --- a/protoguide-frontend/src/main.js +++ b/protoguide-frontend/src/main.js @@ -13,6 +13,7 @@ Vue.use({ install(Vue) { Vue.prototype.$api = axios.create( {baseURL: 'http://localhost:3000/api/v1/'}, + // production : https://guide.nes.uni-due.de/api/api/v1/ {cache: false} ) } diff --git a/protoguide-frontend/src/views/Report.vue b/protoguide-frontend/src/views/Report.vue index a3738eb..1b8f205 100644 --- a/protoguide-frontend/src/views/Report.vue +++ b/protoguide-frontend/src/views/Report.vue @@ -335,8 +335,8 @@ items: function () { const children = this.nodes; return [{ - id: 1, - name: 'Computer Science', + id: 0, + name: 'Fields', children: children }] },