Skip to content

Commit

Permalink
update search method
Browse files Browse the repository at this point in the history
  • Loading branch information
suqingdong committed Aug 28, 2020
1 parent 7dcf7eb commit 3702d24
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions impact_factor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
DEFAULT_DB = os.path.join(BASE_DIR, 'data', 'impact_factor.db')

__version__ = '1.0.3'
__version__ = '1.0.5'
__author__ = 'suqingdong'
__author_email__ = '[email protected]'

Expand Down Expand Up @@ -63,6 +63,7 @@ def search(self, value, field=None, like=True):
for key in ('issn', 'e_issn', 'journal', 'med_abbr', 'nlm_id'):
context = self.manager.query(Factor, key, value, like=like)
if context:
context['factor_history'] = json.loads(context['factor_history'])
return context

def pubmed_filter(self, min_value=None, max_value=None, indexed=None, outfile=None, **kwargs):
Expand All @@ -72,12 +73,13 @@ def pubmed_filter(self, min_value=None, max_value=None, indexed=None, outfile=No
if min_value is not None:
res = res.filter(Factor.factor >= min_value)
if max_value is not None:
res = res.filter(Factor.factor <= max_value)
res = res.filter(Factor.factor < max_value)

if res.count() > 4000:
print('total {n} journals with IF: {min_value} - {max_value} (limit 4000)'.format(n=res.count(), **locals()))
issn_list = '|'.join(each.issn or '"{}"[Journal]'.format(each.med_abbr) for each in res)

if len(issn_list) > 4000:
print('total {n} journals with IF: {min_value} - {max_value} (exceed 4000 characters)'.format(n=res.count(), **locals()))
else:
issn_list = '|'.join(each.issn or '"{}"[Journal]'.format(each.med_abbr) for each in res)
print('{n} journals with IF: {min_value} - {max_value}'.format(n=res.count(), **locals()))
if outfile:
with util.safe_open(outfile, 'w') as out:
Expand Down

0 comments on commit 3702d24

Please sign in to comment.