Skip to content

Commit

Permalink
Inclusão de gráfico de fator de impacto JCR
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiobatalha committed Jul 27, 2017
1 parent 5f5ab9e commit d20e18d
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 4 deletions.
1 change: 1 addition & 0 deletions analytics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def add_chartsconfig(request):
config.add_route('bibliometrics_journal_received_self_and_granted_citation_chart', '/ajx/bibliometrics/journal/received_self_and_granted_citation_chart')
config.add_route('bibliometrics_journal_impact_factor_chart', '/ajx/bibliometrics/journal/impact_factor_chart')
config.add_route('bibliometrics_journal_google_h5m5_chart', '/ajx/bibliometrics/journal/google_h5m5_chart')
config.add_route('bibliometrics_journal_jcr_impact_factor_chart', '/ajx/bibliometrics/journal/jcr_impact_factor_chart')
config.add_route('bibliometrics_document_received_citations', '/ajx/bibliometrics/document/received_citations')
config.add_route('bibliometrics_document_list_received_citations', '/w/bibliometrics/document/list/received_citations')
config.add_request_method(add_stats, 'stats', reify=True)
Expand Down
23 changes: 23 additions & 0 deletions analytics/charts_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,29 @@ def bibliometrics_cited_and_citing_years_heat(self, data):

return {'options': chart}

def bibliometrics_jcr_impact_factor(self, data):

chart = self.highchart

chart['title'] = {'text': self._(u'Fator de Impacto JCR')}
chart['xAxis'] = {'categories': data['categories']}
chart['series'] = data['series']
chart['yAxis']['title'] = {'text': self._(u'Fator de Impacto JCR')}
chart['plotOptions'] = {
'line': {
'dataLabels': {
'enabled': True
}
}
}
chart['tooltip'] = {
'headerFormat': self._(u'Fator de Impacto JCR'),
'pointFormat': u'<br/><strong>'+self._(u'Ano base')+u'</strong>: {point.category}<br/><strong>{series.name}</strong>: {point.y}',
'followPointer': False,
}

return {'options': chart}

def bibliometrics_google_h5m5(self, data):

chart = self.highchart
Expand Down
45 changes: 45 additions & 0 deletions analytics/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,51 @@ def jcr(self, issn, raw=False):

return data

def _compute_jcr_impact_factor(self, data):

series = []
categories = []

five_year_impact_factor = {
'name': 'five_year_impact_factor',
'data': []
}

journal_impact_factor = {
'name': 'journal_impact_factor',
'data': []
}

impact_factor_without_journal_self_cites = {
'name': 'impact_factor_without_journal_self_cites',
'data': []
}

for year, data in sorted(data.items()):
categories.append(year)
five_year_impact_factor["data"].append(
{'y': float(data['five_year_impact_factor']) if data['five_year_impact_factor'] else None}
)
journal_impact_factor["data"].append(
{'y': float(data['journal_impact_factor']) if data['journal_impact_factor'] else None})
impact_factor_without_journal_self_cites["data"].append(
{'y': float(data['impact_factor_without_journal_self_cites']) if data['impact_factor_without_journal_self_cites'] else None})

series.append(five_year_impact_factor)
series.append(journal_impact_factor)
series.append(impact_factor_without_journal_self_cites)

return {"series": series, "categories": categories}

def jcr_impact_factor(self, issn, raw=False):

data = jcrindicators.get_indicators(issn) or {}

if raw:
return data

return self._compute_jcr_impact_factor(data)

def document_received_citations(self, document, py_range=None):

try:
Expand Down
7 changes: 5 additions & 2 deletions analytics/templates/website/bibliometrics_journal_jcr.mako
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
</div>
% else:
<h3>${_('Indicadores JCR')}</h3>
<h2>${_('Indicadores JCR')}</h2>
% if len(jcr) == 0:
<div class="row">
<div class="col-md-12">
Expand All @@ -22,7 +22,10 @@
</div>
</div>
% endif
% for year, data in jcr.items():
<h3>${_('Fator de impacto')}</h3>
<%include file="bibliometrics_journal_jcr_impact_factor.mako"/>
<h3>${_('Dados de todos os anos')}</h3>
% for year, data in sorted(jcr.items(), reverse=True):
<h4>base year: ${ year }</h4>
<div class="row">
<div class="col-md-1">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## coding: utf-8
<div id="jcr_impact_factor_chart" style="width:100%; height:400px;">
<span id="loading_jcr_impact_factor_chart">
<img src="/static/images/loading.gif" />
<h5>${_(u'loading')}</h5>
</span>
</div>
<script language="javascript">
$("#loading_jcr_impact_factor_chart").show();
$(document).ready(function() {
var url = "${request.route_url('bibliometrics_journal_jcr_impact_factor_chart')}?journal=${selected_code}&callback=?";
$.getJSON(url, function(data) {
% if selected_journal:
data['options']['subtitle'] = {'text': '${selected_journal}'};
% endif
data.options.plotOptions.series = {
'cursor': 'pointer',
'point': {
'events': {
'click': function() {
window.open(this.ownURL);
}
}
}
};
$('#jcr_impact_factor_chart').highcharts(data['options']);
$("#loading_jcr_impact_factor_chart").hide();
});
});
</script>
13 changes: 13 additions & 0 deletions analytics/views_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ def bibliometrics_document_received_citations(request):
return data




@view_config(route_name='bibliometrics_journal_jcr_impact_factor_chart', request_method='GET', renderer='jsonp')
@base_data_manager
def bibliometrics_journal_jcr_impact_factor_chart(request):

data = request.data_manager

data = request.stats.bibliometrics.jcr_impact_factor(data['selected_journal_code'])

return request.chartsconfig.bibliometrics_jcr_impact_factor(data)


@view_config(route_name='bibliometrics_journal_google_h5m5_chart', request_method='GET', renderer='jsonp')
@base_data_manager
def bibliometrics_journal_google_h5m5_chart(request):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

setup(
name="analytics",
version='1.27.0',
version='1.28.0',
description="A analytics frontend for SciELO usage and publication statistics",
author="SciELO",
author_email="[email protected]",
Expand Down
148 changes: 147 additions & 1 deletion tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,153 @@ def setUp(self):
self._path = os.path.dirname(os.path.realpath(__file__))
self._stats = controller.Stats('localhost:11600', 'localhost:11600', 'localhost:11600', 'localhost:11600')

def test_compute_jcr_impact_factor(self):

data = {
"2014": {
"article_influence_score": 0.172,
"cited_half_life": "5.3",
"percentage_articles_in_citable_items": 98.76,
"issn_scielo": "0102-8650",
"normalized_eigenfactor": 0.18137,
"five_year_impact_factor": 0.778,
"immediacy_index": 0.068,
"citable_items": 161,
"impact_factor_without_journal_self_cites": 0.513,
"total_cites": 849,
"year": 2014,
"eigenfactor_score": 0.00162,
"journal_impact_factor": 0.661,
"citing_half_life": "9.3",
"average_journal_impact_factor_percentile": 15.404
},
"2011": {
"article_influence_score": None,
"cited_half_life": "4.9",
"percentage_articles_in_citable_items": 100.0,
"issn_scielo": "0102-8650",
"normalized_eigenfactor": None,
"five_year_impact_factor": None,
"immediacy_index": 0.108,
"citable_items": 111,
"impact_factor_without_journal_self_cites": 0.462,
"total_cites": 550,
"year": 2011,
"eigenfactor_score": 0.00125,
"journal_impact_factor": 0.584,
"citing_half_life": "9.3",
"average_journal_impact_factor_percentile": 16.834
},
"2015": {
"article_influence_score": 0.165,
"cited_half_life": "5.2",
"percentage_articles_in_citable_items": 99.19,
"issn_scielo": "0102-8650",
"normalized_eigenfactor": 0.19143,
"five_year_impact_factor": 0.764,
"immediacy_index": 0.081,
"citable_items": 123,
"impact_factor_without_journal_self_cites": 0.465,
"total_cites": 913,
"year": 2015,
"eigenfactor_score": 0.00168,
"journal_impact_factor": 0.58,
"citing_half_life": "8.8",
"average_journal_impact_factor_percentile": 11.25
},
"2016": {
"article_influence_score": 0.159,
"cited_half_life": "5.5",
"percentage_articles_in_citable_items": 99.23,
"issn_scielo": "0102-8650",
"normalized_eigenfactor": 0.18478,
"five_year_impact_factor": 0.735,
"immediacy_index": 0.138,
"citable_items": 130,
"impact_factor_without_journal_self_cites": 0.616,
"total_cites": 1004,
"year": 2016,
"eigenfactor_score": 0.00161,
"journal_impact_factor": 0.729,
"citing_half_life": "8.3",
"average_journal_impact_factor_percentile": 14.031
},
"2009": {
"article_influence_score": None,
"cited_half_life": "4.4",
"percentage_articles_in_citable_items": 100.0,
"issn_scielo": "0102-8650",
"normalized_eigenfactor": None,
"five_year_impact_factor": None,
"immediacy_index": 0.062,
"citable_items": 81,
"impact_factor_without_journal_self_cites": 0.383,
"total_cites": 407,
"year": 2009,
"eigenfactor_score": 0.00117,
"journal_impact_factor": 0.479,
"citing_half_life": ">10.0",
"average_journal_impact_factor_percentile": 15.868
},
"2010": {
"article_influence_score": None,
"cited_half_life": "4.6",
"percentage_articles_in_citable_items": 100.0,
"issn_scielo": "0102-8650",
"normalized_eigenfactor": None,
"five_year_impact_factor": None,
"immediacy_index": 0.065,
"citable_items": 92,
"impact_factor_without_journal_self_cites": 0.403,
"total_cites": 423,
"year": 2010,
"eigenfactor_score": 0.00128,
"journal_impact_factor": 0.5,
"citing_half_life": "9.4",
"average_journal_impact_factor_percentile": 14.628
},
"2012": {
"article_influence_score": 0.133,
"cited_half_life": "6.1",
"percentage_articles_in_citable_items": 98.11,
"issn_scielo": "0102-8650",
"normalized_eigenfactor": None,
"five_year_impact_factor": 0.695,
"immediacy_index": 0.075,
"citable_items": 159,
"impact_factor_without_journal_self_cites": 0.468,
"total_cites": 693,
"year": 2012,
"eigenfactor_score": 0.0011,
"journal_impact_factor": 0.626,
"citing_half_life": "8.7",
"average_journal_impact_factor_percentile": 19.849
},
"2013": {
"article_influence_score": 0.145,
"cited_half_life": "5.6",
"percentage_articles_in_citable_items": 98.68,
"issn_scielo": "0102-8650",
"normalized_eigenfactor": 0.14633,
"five_year_impact_factor": 0.677,
"immediacy_index": 0.06,
"citable_items": 151,
"impact_factor_without_journal_self_cites": 0.422,
"total_cites": 708,
"year": 2013,
"eigenfactor_score": 0.00133,
"journal_impact_factor": 0.57,
"citing_half_life": "9.1",
"average_journal_impact_factor_percentile": 14.951
}
}

expected = {}

result = self._stats.bibliometrics._compute_jcr_impact_factor(data)

self.assertEqual(result, expected)

def test_compute_h5m5_without_data(self):

data = None
Expand All @@ -26,7 +173,6 @@ def test_compute_h5m5_without_data(self):

self.assertEqual(result, {'series': [{'data': [], 'name': 'H5'}, {'data': [], 'name': 'M5'}], 'categories': []})


def test_compute_h5m5(self):

data = {
Expand Down

0 comments on commit d20e18d

Please sign in to comment.