Add notes for 2018-09-18

This commit is contained in:
2018-09-18 15:52:20 +03:00
parent 817f470888
commit d41afc28d4
3 changed files with 62 additions and 8 deletions

View File

@ -335,4 +335,29 @@ $ http 'http://localhost:3000/solr/statistics/select?indent=on&rows=0&q=type:0+o
- That one returns 766, which is exactly 1655 minus 889...
- Also, Solr's `fq` is similar to the regular `q` query parameter, but it is considered for the Solr query cache so it should be faster for multiple queries
## 2018-09-18
- I managed to create a simple proof of concept REST API to expose item view and download statistics: [cgspace-statistics-api](https://github.com/alanorth/cgspace-statistics-api)
- It uses the Python-based [Falcon](https://falcon.readthedocs.io) web framework and talks to Solr directly using the [SolrClient](https://github.com/moonlitesolutions/SolrClient) library (which seems to have issues in Python 3.7 currently)
- After deploying on DSpace Test I can then get the stats for an item using its ID:
```
$ http -b 'https://dspacetest.cgiar.org/rest/statistics/item?id=110988'
{
"downloads": 2,
"id": 110988,
"views": 15
}
```
- The numbers are different than those that come from Atmire's statlets for some reason, but as I'm querying Solr directly, I have no idea where their numbers come from!
- Moayad from CodeObia asked if I could make the API be able to paginate over all items, for example: /statistics?limit=100&page=1
- Getting all the item IDs from PostgreSQL is certainly easy:
```
dspace=# select item_id from item where in_archive is True and withdrawn is False and discoverable is True;
```
- The rest of the Falcon tooling will be more difficult...
<!-- vim: set sw=2 ts=2: -->