Skip to content

Commit

Permalink
fix missing metrics bug
Browse files Browse the repository at this point in the history
Some metrics skipped after rendering an invalid graph. Check graphs valid for each metrics before rendering
  • Loading branch information
shinyichen authored and thostetler committed Jan 17, 2024
1 parent 8cbc24b commit f1f5c84
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/js/widgets/metrics/widget.js
Expand Up @@ -1242,14 +1242,33 @@ define([
}
},

insertViews: function() {
insertViews: function(data) {
// render the container view
this.view.render();
// attach table and graph views
['papers', 'citations', 'indices', 'reads'].forEach(function(name) {
this.view[name + 'Table'].show(this.childViews[name + 'TableView']);
this.view[name + 'Graph'].show(this.childViews[name + 'GraphView']);
}, this);

this.view.papersTable.show(this.childViews.papersTableView);
if (this.hasPapers(data)) {
this.view.papersGraph.show(this.childViews.papersGraphView);
}

this.view.citationsTable.show(this.childViews.citationsTableView);
if (this.hasCitations(data)) {
this.view.citationsGraph.show(this.childViews.citationsGraphView);
}

this.view.readsTable.show(this.childViews.readsTableView);
if (this.hasReads(data)) {
this.view.readsGraph.show(this.childViews.readsGraphView);
}

if (this.hasIndicesTable(data)) {
this.view.indicesTable.show(this.childViews.indicesTableView);
}

if (this.hasIndicesGraph(data)) {
this.view.indicesGraph.show(this.childViews.indicesGraphView);
}
this.view.showDownloadButtons(this.childViews);
},

Expand Down Expand Up @@ -1420,6 +1439,10 @@ define([
return data;
},

hasPapers: function(data) {
return data['basic stats']['number of papers'] > 0;
},

hasCitations: function(data) {
return data['citation stats']['total number of citations'] > 0;
},
Expand All @@ -1428,6 +1451,14 @@ define([
return data['basic stats']['total number of reads'] > 0;
},

hasIndicesTable: function(data) {
return !!data['indicators'] && !!data['indicators refereed'];
},

hasIndicesGraph: function(data) {
return !!data['time series'];
},

/*
* end functions for 1 paper
* */
Expand Down

0 comments on commit f1f5c84

Please sign in to comment.