diff --git a/content/posts/2018-09.md b/content/posts/2018-09.md index b043492a8..ec40db592 100644 --- a/content/posts/2018-09.md +++ b/content/posts/2018-09.md @@ -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... + diff --git a/docs/2018-09/index.html b/docs/2018-09/index.html index 4811fa239..b72849a38 100644 --- a/docs/2018-09/index.html +++ b/docs/2018-09/index.html @@ -18,7 +18,7 @@ I’m testing the new DSpace 5.8 branch in my Ubuntu 18.04 environment and I " /> - + 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

+ + + +
$ http -b 'https://dspacetest.cgiar.org/rest/statistics/item?id=110988'
+{
+    "downloads": 2,
+    "id": 110988,
+    "views": 15
+}
+
+ + + +
dspace=# select item_id from item where in_archive is True and withdrawn is False and discoverable is True;
+
+ + + diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 00d5dbda6..45879c14f 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -4,7 +4,7 @@ https://alanorth.github.io/cgspace-notes/2018-09/ - 2018-09-17T19:53:08+03:00 + 2018-09-18T01:16:21+03:00 @@ -184,7 +184,7 @@ https://alanorth.github.io/cgspace-notes/ - 2018-09-17T19:53:08+03:00 + 2018-09-18T01:16:21+03:00 0 @@ -195,7 +195,7 @@ https://alanorth.github.io/cgspace-notes/tags/notes/ - 2018-09-17T19:53:08+03:00 + 2018-09-18T01:16:21+03:00 0 @@ -207,13 +207,13 @@ https://alanorth.github.io/cgspace-notes/posts/ - 2018-09-17T19:53:08+03:00 + 2018-09-18T01:16:21+03:00 0 https://alanorth.github.io/cgspace-notes/tags/ - 2018-09-17T19:53:08+03:00 + 2018-09-18T01:16:21+03:00 0