mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2025-05-10 15:16:02 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
702724e8a4
|
|||
36818d03ef
|
|||
4cf8656b35
|
|||
f30a464cd1
|
|||
93ae12e313
|
|||
dc978e9333
|
|||
295436fea0
|
|||
46a1476ab0
|
8
.travis.yml
Normal file
8
.travis.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
language: python
|
||||||
|
python:
|
||||||
|
- "3.5"
|
||||||
|
- "3.6"
|
||||||
|
install:
|
||||||
|
- pip install -r requirements.txt
|
||||||
|
|
||||||
|
# vim: ts=2 sw=2 et
|
@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.3.0] - 2018-09-25
|
||||||
|
### Added
|
||||||
|
- requirements.txt for pip
|
||||||
|
- Travis CI build configuration for Python 3.6 and 3.7
|
||||||
|
- Documentation on using the API
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- The "all items" route from / to /items
|
||||||
|
|
||||||
## [0.2.1] - 2018-09-24
|
## [0.2.1] - 2018-09-24
|
||||||
### Changed
|
### Changed
|
||||||
- Environment settings in example systemd unit files
|
- Environment settings in example systemd unit files
|
||||||
|
13
README.md
13
README.md
@ -1,22 +1,31 @@
|
|||||||
# DSpace Statistics API
|
# DSpace Statistics API
|
||||||
A quick and dirty REST API to expose Solr view and download statistics for items in a DSpace repository.
|
A quick and dirty REST API to expose Solr view and download statistics for items in a DSpace repository.
|
||||||
|
|
||||||
Written and tested in Python 3.6. SolrClient (0.2.1) does not currently run in Python 3.7.0. Requires PostgreSQL version 9.5 or greater for [`UPSERT` support](https://wiki.postgresql.org/wiki/UPSERT).
|
Written and tested in Python 3.5 and 3.6. SolrClient (0.2.1) does [not currently run in Python 3.7.0](https://github.com/moonlitesolutions/SolrClient/issues/79). Requires PostgreSQL version 9.5 or greater for [`UPSERT` support](https://wiki.postgresql.org/wiki/UPSERT).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Create a virtual environment and run it:
|
Create a virtual environment and run it:
|
||||||
|
|
||||||
$ virtualenv -p /usr/bin/python3.6 venv
|
$ virtualenv -p /usr/bin/python3.6 venv
|
||||||
$ . venv/bin/activate
|
$ . venv/bin/activate
|
||||||
$ pip install falcon gunicorn SolrClient psycopg2-binary
|
$ pip install -r requirements.txt
|
||||||
$ gunicorn app:api
|
$ gunicorn app:api
|
||||||
|
|
||||||
|
## Using the API
|
||||||
|
The API exposes the following endpoints:
|
||||||
|
|
||||||
|
- GET `/items` — return views and downloads for all items that Solr knows about¹. Accepts `limit` and `page` query parameters for pagination of results.
|
||||||
|
- GET `/item/id` — return views and downloads for a single item (*id* must be a positive integer).
|
||||||
|
|
||||||
|
¹ We are querying the Solr statistics core, which technically only knows about all items that have either views or downloads.
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
|
|
||||||
- Add API documentation
|
- Add API documentation
|
||||||
- Close up DB connection when gunicorn shuts down gracefully
|
- Close up DB connection when gunicorn shuts down gracefully
|
||||||
- Better logging
|
- Better logging
|
||||||
- Return HTTP 404 when item_id is nonexistent
|
- Return HTTP 404 when item_id is nonexistent
|
||||||
|
- Tests
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This work is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
|
This work is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
|
||||||
|
2
app.py
2
app.py
@ -59,7 +59,7 @@ class ItemResource:
|
|||||||
resp.media = statistics
|
resp.media = statistics
|
||||||
|
|
||||||
api = falcon.API()
|
api = falcon.API()
|
||||||
api.add_route('/', AllItemsResource())
|
api.add_route('/items', AllItemsResource())
|
||||||
api.add_route('/item/{item_id:int}', ItemResource())
|
api.add_route('/item/{item_id:int}', ItemResource())
|
||||||
|
|
||||||
# vim: set sw=4 ts=4 expandtab:
|
# vim: set sw=4 ts=4 expandtab:
|
||||||
|
12
requirements.txt
Normal file
12
requirements.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
certifi==2018.8.24
|
||||||
|
chardet==3.0.4
|
||||||
|
falcon==1.4.1
|
||||||
|
gunicorn==19.9.0
|
||||||
|
idna==2.7
|
||||||
|
kazoo==2.2.1
|
||||||
|
psycopg2-binary==2.7.5
|
||||||
|
python-mimeparse==1.6.0
|
||||||
|
requests==2.19.1
|
||||||
|
six==1.11.0
|
||||||
|
SolrClient==0.2.1
|
||||||
|
urllib3==1.23
|
Reference in New Issue
Block a user