ilri / OpenRXV

OpenRXV is a repository harvesting and explorer tool utilizing Dublin Core and CG Core metadata schemas
GNU General Public License v3.0
4 stars 6 forks source link

Enable date-based usage statistics from the DSpace Statistics API #56

Open alanorth opened 3 years ago

alanorth commented 3 years ago

View and download statistics are currently "all time" due to limitations of the DSpace Statistics API. We should explore the possibility of enabling a "reporting period". The current version of the API supports date ranges so we can now limit statistics to a date range by POSTing community, collection, or item IDs and date parameters.

For example, if you send this request:

{
    "limit": 100,
    "page": 0,
    "dateFrom": "2020-01-01T00:00:00Z",
    "dateTo": "2020-11-18T00:00:00Z",
    "items": [
        "926ffacd-1916-4366-a420-a966c195295f",
        "e8c64069-78ba-4472-b5b2-72d705f04ca7",
        "e9ac05b8-3270-4e2f-83fb-45e3c65e0c9c",
        "326c00a4-977e-4d32-968a-c372b18bf8c0"
    ]
}

The API will respond:

{
   "currentPage" : 0,
   "limit" : 100,
   "statistics" : [
      {
         "downloads" : 0,
         "id" : "e9ac05b8-3270-4e2f-83fb-45e3c65e0c9c",
         "views" : 420
      },
      {
         "downloads" : 0,
         "id" : "e8c64069-78ba-4472-b5b2-72d705f04ca7",
         "views" : 37
      },
      {
         "downloads" : 0,
         "id" : "326c00a4-977e-4d32-968a-c372b18bf8c0",
         "views" : 10
      },
      {
         "downloads" : 9,
         "id" : "926ffacd-1916-4366-a420-a966c195295f",
         "views" : 4
      }
   ],
   "totalPages" : 0
}

The problem is that this is only feasible for hundreds or thousands of items, but not the entire repository. We could enable it as an option when generating a report perhaps, rather than for the entire AReS Explorer UI. See the Swagger API docs.

alanorth commented 3 years ago

A better way to think about this would be as a "reporting period" actually, for example to see how many views/downloads took place during a certain date range.

See the DSpace Statistics API documentation for the new endpoints that allow POSTing a date range with a list of IDs:

https://dspacetest.cgiar.org/rest/statistics/swagger