mirror of
https://github.com/chenasraf/snpr.git
synced 2026-05-18 01:39:01 +00:00
* Renaming '.env.example' to '.env' * Removing bootstrap gem * Adding newest version of Bootstrap(3.3.6) and setting it up * Renamed 'database.yml.example' to 'database.yml' * Deleted common.css.scss * Deleting active_admin/application requirement * Adding style file that import all style partials and adding javascript file * Updating application.html.erb and includes(footer and navbar) * Removing from news all the updates(new users, new pheno...) and putting on updates page * Updating user views * Updating phenotype views * Updating index page * Updating FAQ and Stats pages * Updating genotype views * Updating messages views * Updating snps views and signin page * Updating fitbit and picture_phenotype views * Updating warning * Adding base style and variable of style * Adding style of index, faq and stats page * Adding style for user views * Adding style for footer and navbar * Adding modules of style * Adding style for fitbit, genotype, phenotype and message views * Adding style for snps and updates views * Updating serverscript * Adding new logo and RSS new image * Adding style files for: comments, password reset, picture phenotypes, achievements and search results * Removing !important and updating some styles * Updating view from achievements * Updating views from fitbit profiles * Updating genotypes views * Updating navbar view * Updating password reset view * Updating phenotype comments views * Updating phenotypes views * Updating views: search result, snps, user phenotypes and users * Updating views: updates and picture phenotypes * Adding updates page's routes * Modify flash messages and change number of fitbit profiles and genotypes per page(20 -> 15) * Replace will_paginate to a version that works with bootstraps * Change serverscript to make Sidekiq work propely * Updates user's views * Updates script to run only when page is fully loaded * Moves script tags to head and updates flash messages' views * Updates and add style for: picture_phenotypes, snps, userpages, press, warnings * Updates views for: genotypes, messages, fitbit_profiles, phenotype comments, phenotypes * Updates views for: picture phenotype, picture phenotype comments, warnings and errors, snps, snps comments * Updates views for: press, picture phenotype user, user session and snps user * Updates views from: user, updates, press and stats * Updates views from: snps, picture phenotypes, phenotypes, genotypes * Updates views from: fitbit profiles, navbar, application, messages and news * Updates script file * Updates style files * Changes modal views * Renaming '.env.example' to '.env' * Removing bootstrap gem * Adding newest version of Bootstrap(3.3.6) and setting it up * Renamed 'database.yml.example' to 'database.yml' * Deleted common.css.scss * Deleting active_admin/application requirement * Adding style file that import all style partials and adding javascript file * Updating application.html.erb and includes(footer and navbar) * Removing from news all the updates(new users, new pheno...) and putting on updates page * Updating user views * Updating phenotype views * Updating index page * Updating FAQ and Stats pages * Updating genotype views * Updating messages views * Updating snps views and signin page * Updating fitbit and picture_phenotype views * Updating warning * Adding base style and variable of style * Adding style of index, faq and stats page * Adding style for user views * Adding style for footer and navbar * Adding modules of style * Adding style for fitbit, genotype, phenotype and message views * Adding style for snps and updates views * Updating serverscript * Adding new logo and RSS new image * Adding style files for: comments, password reset, picture phenotypes, achievements and search results * Removing !important and updating some styles * Updating view from achievements * Updating views from fitbit profiles * Updating genotypes views * Updating navbar view * Updating password reset view * Updating phenotype comments views * Updating phenotypes views * Updating views: search result, snps, user phenotypes and users * Updating views: updates and picture phenotypes * Adding updates page's routes * Modify flash messages and change number of fitbit profiles and genotypes per page(20 -> 15) * Replace will_paginate to a version that works with bootstraps * Change serverscript to make Sidekiq work propely * Updates user's views * Updates script to run only when page is fully loaded * Moves script tags to head and updates flash messages' views * Updates and add style for: picture_phenotypes, snps, userpages, press, warnings * Updates views for: genotypes, messages, fitbit_profiles, phenotype comments, phenotypes * Updates views for: picture phenotype, picture phenotype comments, warnings and errors, snps, snps comments * Updates views for: press, picture phenotype user, user session and snps user * Updates views from: user, updates, press and stats * Updates views from: snps, picture phenotypes, phenotypes, genotypes * Updates views from: fitbit profiles, navbar, application, messages and news * Updates script file * Updates style files * Changes modal views * Updates script file * Add style file for modal * Updates views from: snp comments, user phenotypes, modal and picture phenotypes * Removes empty style files * Moves comments style to modules directory * Creates a more general class for containers and titles * Removing more specific classes for containers and titles * Changes load order, now variables are loaded before base styles * Replaces all containers and titles classes with the more general class for them * Corrects styles order and organization * Updates minimum height for content container * Organizes and refactors script file * Updates views for fitbit and user * Removes 'test-' from all classes and updates some views * Updates settings view * Updates gitignore * Changes config files * Removes some file from .gitignore * Readds the example files * Changes all unnecessary double-quotes to single-quotes * Corrects script file * Updates hound file to ignore JS files * Hopefully merged both * fixes typos, gem installation * Adds missing pagination gem * Deletes Vagrantfile * Automatically replaced all pre Ruby 1.9 hashes with new style to satisfy Hound * More changes for Hound, triggered by me automatically changing the hash syntax * More hound changes * Fully satisfy the hound * Fix some more style issues, delete some old Vagrant stuff * Fix usermailer complaints * Changed some stuff in fitbit notification worker - prob. needs bigger refactor, long lines, cannot change * Two more borked tests * Get rid of useless asset pipeline errors * Skipping search test for now. * added about us here * disclaimer now also for genotypes * working a bit on the hound * fixed FAQ language
57 lines
2.3 KiB
Ruby
57 lines
2.3 KiB
Ruby
# frozen_string_literal: true
|
|
require 'rubygems'
|
|
require 'net/http'
|
|
require 'json'
|
|
|
|
class PlosDetails
|
|
include Sidekiq::Worker
|
|
sidekiq_options queue: :plos_details, retry: 5, unique: true
|
|
|
|
def perform(plos_paper)
|
|
plos_paper_id =
|
|
if plos_paper.is_a?(Hash)
|
|
plos_paper['plos_paper']['id'].to_i
|
|
else
|
|
plos_paper.to_i
|
|
end
|
|
|
|
plos_paper = PlosPaper.find_by_id(plos_paper_id)
|
|
|
|
detail_url = "http://alm.plos.org/api/v3/articles/#{plos_paper.doi}?" \
|
|
"api_key=#{ENV.fetch('PLOS_API_KEY')}"
|
|
|
|
detail_resp = Net::HTTP.get_response(URI.parse(detail_url))
|
|
# did we get a proper response?
|
|
unless detail_resp.is_a? Net::HTTPSuccess
|
|
# don't bother parsing broken or empty output
|
|
sleep 6
|
|
return
|
|
end
|
|
|
|
detail_data = detail_resp.body
|
|
detail_result = JSON.parse(detail_data)
|
|
|
|
# as of 2016-02-10, body is of format
|
|
# {'doi':'10.1371/journal.pone.0080003','title':'Plasma Interferon-Gamma-Inducible Protein-10 Levels Are Associated with Early,
|
|
# but Not Sustained Virological Response during Treatment of Acute or Early Chronic HCV Infection',
|
|
# 'url':'http://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0080003',
|
|
# 'mendeley':'21a5a7c7-9531-38d1-9555-871b62ebf9d1','pmid':'24278230','pmcid':'3835825','publication_date':'2013-11-20T08:00:00Z',
|
|
# 'update_date':'2016-02-09T23:22:24Z','views':1720,'shares':0,'bookmarks':5,'citations':4,
|
|
# currently we're only interested in 'views', but there's also tons of other data coming back (shares/comments on reddit, for example)
|
|
# 'sources':
|
|
# [{'name':'openedition','display_name':'OpenEdition','events_url':null,'update_date':'2013-11-21T11:15:10Z',
|
|
# 'metrics':{'pdf':0,'html':0,'shares':0,'groups':0,'comments':0,'likes':0,'citations':0,'total':0}},
|
|
# {'name':'reddit','display_name':'Reddit','events_url':null,'update_date':'2015-12-30T13:12:53Z',
|
|
# 'metrics':{'pdf':0,'html':0,'shares':0,'groups':0,'comments':0,'likes':0,'citations':0,'total':0}},
|
|
# ....
|
|
# {'name':'orcid','display_name':'ORCID','events_url':null,'update_date':'2016-02-03T09:06:31Z',
|
|
# 'metrics':{'pdf':0,'html':0,'shares':0,'groups':0,'comments':0,'likes':0,'citations':0,'total':0}}]}
|
|
#
|
|
readers_total = detail_result['views']
|
|
|
|
plos_paper.reader = readers_total.to_i
|
|
plos_paper.save
|
|
sleep(6)
|
|
end
|
|
end
|