Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

API to export citations #104

Closed
kaplun opened this issue Sep 1, 2015 · 1 comment
Closed

API to export citations #104

kaplun opened this issue Sep 1, 2015 · 1 comment

Comments

@kaplun
Copy link
Contributor

kaplun commented Sep 1, 2015

We need a way to compute citations on legacy and export them into labs.

For this reason we need in labs to have corresponding models for:

-- a table for logging changes in the citation dict
CREATE TABLE IF NOT EXISTS rnkCITATIONLOG (
  id int(11) unsigned NOT NULL auto_increment,
  citee int(10) unsigned NOT NULL,
  citer int(10) unsigned NOT NULL,
  `type` ENUM('added', 'removed'),
  action_date datetime NOT NULL,
  PRIMARY KEY (id),
  KEY citee (citee),
  KEY citer (citer)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS rnkCITATIONDICT (
  citee int(10) unsigned NOT NULL,
  citer int(10) unsigned NOT NULL,
  last_updated datetime NOT NULL,
  PRIMARY KEY id (citee, citer),
  KEY reverse (citer, citee)
) ENGINE=MyISAM;

A simpler handler could be built on prod to export the citation log.

E.g.

file citation.py:

from json import dumps

from invenio.dbquery import run_sql

def index(req, action_date="1970-01-01 00:00:00"):
    req.set_header("content-type", "application/json")
    res = run_sql("SELECT id, citee, citer, type, action_date 
                   FROM rnkCITATIONLOG WHERE action_date>=%s 
                   ORDER BY action_date ASC LIMIT 100000", (action_date, ))
    comma = ""
    req.write("{")
    for row in res:
        req.write("%s%s" % (comma, dumps(row))
        req.flush()
        comma = ","
    req.write("}")

Then a simple query to:

http://inspirehep.net/citations.py?action_date=2015-01-01

would do the trick :-)

@kaplun kaplun closed this as completed in ddbb1d9 Sep 7, 2015
@kaplun
Copy link
Contributor Author

kaplun commented Sep 7, 2015

@Panos512 here is the corresponding ticket for the prod side :-)

Note the description above the interface has been modified to use directly the id of the row.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant