1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2025-02-16 23:14:54 +01:00

Compare commits

..

No commits in common. "d1c177e146550d63d61dc22b204df5560d1a1249" and "a02211fd609cd46e8474b2e2d8e4b2e45392429d" have entirely different histories.

7 changed files with 15 additions and 24 deletions

View File

@ -24,7 +24,7 @@ steps:
commands:
- id
- python -V
- apt update && apt install -y gcc git
- apt update && apt install -y gcc
- pip install -r requirements-dev.txt
- pytest
@ -71,7 +71,6 @@ steps:
commands:
- id
- python -V
- apt update && apt install -y git
- pip install -r requirements-dev.txt
- pytest
@ -110,7 +109,6 @@ steps:
commands:
- id
- python -V
- apt update && apt install -y git
- pip install -r requirements-dev.txt
- pytest
@ -149,7 +147,6 @@ steps:
commands:
- id
- python -V
- apt update && apt install -y git
- pip install -r requirements-dev.txt
- pytest

View File

@ -4,7 +4,7 @@ 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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.4.0] - 2020-12-27
## Unreleased
### Added
- indexer.py now indexes views and downloads for communities and collections
- API endpoints for /communities, /community/id, /collections, and /collections/id
@ -16,7 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
deterministically
- Use `fl` parameter in indexer to return only the field we are faceting by
- Minor refactoring of imports for PEP8 style
- More correct calculation of `totalPages` parameter in REST API response
## [1.3.2] - 2020-11-18
### Fixed

View File

@ -1,5 +1,4 @@
import json
import math
import falcon
import psycopg2.extras
@ -17,9 +16,9 @@ class RootResource:
resp.content_type = "text/html"
docs_html = (
"<!DOCTYPE html>"
'<html lang="en-US">'
"<html lang=\"en-US\">"
" <head>"
' <meta charset="UTF-8">'
" <meta charset=\"UTF-8\">"
" <title>DSpace Statistics API</title>"
" </head>"
" <body>"
@ -58,9 +57,6 @@ class OpenAPIJSONResource:
if DSPACE_STATISTICS_API_URL != "":
data["servers"] = [{"url": DSPACE_STATISTICS_API_URL}]
# Set the version in the schema so Swagger UI can display it
data["info"]["version"] = VERSION
resp.body = json.dumps(data)
@ -79,7 +75,7 @@ class AllStatisticsResource:
with db.cursor() as cursor:
# get total number of communities/collections/items so we can estimate the pages
cursor.execute(f"SELECT COUNT(id) FROM {req.context.statistics_scope}")
pages = math.ceil(cursor.fetchone()[0] / limit)
pages = round(cursor.fetchone()[0] / limit)
# get statistics and use limit and offset to page through results
cursor.execute(
@ -132,7 +128,7 @@ class AllStatisticsResource:
# Helper variables to make working with pages/items/results easier and
# to make the code easier to understand
number_of_elements: int = len(req.context.elements)
pages: int = math.ceil(number_of_elements / req.context.limit)
pages: int = int(number_of_elements / req.context.limit)
first_element: int = req.context.page * req.context.limit
last_element: int = first_element + req.context.limit
# Get a subset of the POSTed items based on our limit. Note that Python

View File

@ -16,6 +16,6 @@ DATABASE_PORT = os.environ.get("DATABASE_PORT", "5432")
# the vanilla DSpace REST API.
DSPACE_STATISTICS_API_URL = os.environ.get("DSPACE_STATISTICS_API_URL", "")
VERSION = "1.4.0"
VERSION = "1.4.0-dev"
# vim: set sw=4 ts=4 expandtab:

View File

@ -1,7 +1,7 @@
{
"openapi": "3.0.3",
"info": {
"version": "1.4.0",
"version": "1.4.0-dev",
"title": "DSpace Statistics API",
"description": "A [Falcon-based](https://falcon.readthedocs.io/) web application to make DSpace's item, community, and collection statistics available via a simple REST API. This Swagger interface is powered by [falcon-swagger-ui](https://github.com/rdidyk/falcon-swagger-ui).",
"license": {
@ -142,7 +142,7 @@
},
"example": {
"limit": 100,
"page": 0,
"page": 5,
"dateFrom": "2020-01-01T00:00:00Z",
"dateTo": "2020-12-31T00:00:00Z",
"items": [
@ -502,7 +502,7 @@
},
"example": {
"limit": 100,
"page": 0,
"page": 2,
"dateFrom": "2020-01-01T00:00:00Z",
"dateTo": "2020-12-31T00:00:00Z",
"collections": [

View File

@ -28,8 +28,6 @@
#
# See: https://wiki.duraspace.org/display/DSPACE/Solr
import math
import psycopg2.extras
import requests
@ -77,9 +75,9 @@ def index_views(indexType: str, facetField: str):
exit(0)
# divide results into "pages" and round up to next integer
# divide results into "pages" (cast to int to effectively round down)
results_per_page = 100
results_num_pages = math.ceil(results_totalNumFacets / results_per_page)
results_num_pages = int(results_totalNumFacets / results_per_page)
results_current_page = 0
with DatabaseManager() as db:
@ -160,8 +158,9 @@ def index_downloads(indexType: str, facetField: str):
exit(0)
# divide results into "pages" (cast to int to effectively round down)
results_per_page = 100
results_num_pages = math.ceil(results_totalNumFacets / results_per_page)
results_num_pages = int(results_totalNumFacets / results_per_page)
results_current_page = 0
with DatabaseManager() as db:

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "dspace-statistics-api"
version = "1.4.0"
version = "1.4.0-dev"
description = "A simple REST API to expose Solr view and download statistics for items, communities, and collections in a DSpace repository."
authors = ["Alan Orth <aorth@mjanja.ch>"]
license = "GPL-3.0-only"