mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2025-07-03 04:57:25 +02:00
Compare commits
8 Commits
7de1084f60
...
v1.4.0
Author | SHA1 | Date | |
---|---|---|---|
33dc210452
|
|||
282d5f644a
|
|||
05e0e8bdca
|
|||
2567bb8604
|
|||
4af3c656a3
|
|||
4f8cd1097b
|
|||
a02211fd60
|
|||
fc814593c7
|
@ -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).
|
||||
|
||||
## Unreleased
|
||||
## [1.4.0] - 2020-12-27
|
||||
### Added
|
||||
- indexer.py now indexes views and downloads for communities and collections
|
||||
- API endpoints for /communities, /community/id, /collections, and /collections/id
|
||||
@ -16,6 +16,7 @@ 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
|
||||
|
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import math
|
||||
|
||||
import falcon
|
||||
import psycopg2.extras
|
||||
@ -16,9 +17,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>"
|
||||
@ -57,6 +58,9 @@ 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)
|
||||
|
||||
|
||||
@ -75,7 +79,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 = round(cursor.fetchone()[0] / limit)
|
||||
pages = math.ceil(cursor.fetchone()[0] / limit)
|
||||
|
||||
# get statistics and use limit and offset to page through results
|
||||
cursor.execute(
|
||||
@ -128,7 +132,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 = int(number_of_elements / req.context.limit)
|
||||
pages: int = math.ceil(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
|
||||
|
@ -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-dev"
|
||||
VERSION = "1.4.0"
|
||||
|
||||
# vim: set sw=4 ts=4 expandtab:
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"openapi": "3.0.3",
|
||||
"info": {
|
||||
"version": "1.4.0-dev",
|
||||
"version": "1.4.0",
|
||||
"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": 5,
|
||||
"page": 0,
|
||||
"dateFrom": "2020-01-01T00:00:00Z",
|
||||
"dateTo": "2020-12-31T00:00:00Z",
|
||||
"items": [
|
||||
@ -502,7 +502,7 @@
|
||||
},
|
||||
"example": {
|
||||
"limit": 100,
|
||||
"page": 2,
|
||||
"page": 0,
|
||||
"dateFrom": "2020-01-01T00:00:00Z",
|
||||
"dateTo": "2020-12-31T00:00:00Z",
|
||||
"collections": [
|
||||
|
@ -28,6 +28,8 @@
|
||||
#
|
||||
# See: https://wiki.duraspace.org/display/DSPACE/Solr
|
||||
|
||||
import math
|
||||
|
||||
import psycopg2.extras
|
||||
import requests
|
||||
|
||||
@ -75,9 +77,9 @@ def index_views(indexType: str, facetField: str):
|
||||
|
||||
exit(0)
|
||||
|
||||
# divide results into "pages" (cast to int to effectively round down)
|
||||
# divide results into "pages" and round up to next integer
|
||||
results_per_page = 100
|
||||
results_num_pages = int(results_totalNumFacets / results_per_page)
|
||||
results_num_pages = math.ceil(results_totalNumFacets / results_per_page)
|
||||
results_current_page = 0
|
||||
|
||||
with DatabaseManager() as db:
|
||||
@ -158,9 +160,8 @@ 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 = int(results_totalNumFacets / results_per_page)
|
||||
results_num_pages = math.ceil(results_totalNumFacets / results_per_page)
|
||||
results_current_page = 0
|
||||
|
||||
with DatabaseManager() as db:
|
||||
|
11
poetry.lock
generated
11
poetry.lock
generated
@ -144,6 +144,11 @@ python-versions = "*"
|
||||
falcon = "*"
|
||||
Jinja2 = "*"
|
||||
|
||||
[package.source]
|
||||
url = "https://github.com/alanorth/falcon-swagger-ui.git"
|
||||
reference = "a44244c85dceccfcd249b62fea4ee82a8221e3d2"
|
||||
type = "git"
|
||||
|
||||
[[package]]
|
||||
name = "flake8"
|
||||
version = "3.8.4"
|
||||
@ -589,7 +594,7 @@ testing = ["pytest (>=3.5,<3.7.3 || >3.7.3)", "pytest-checkdocs (>=1.2.3)", "pyt
|
||||
[metadata]
|
||||
lock-version = "1.0"
|
||||
python-versions = "^3.6"
|
||||
content-hash = "1d56758c9e3aa4586109e8aaf4def576d3506385bc749b97e8518f936f2e91ca"
|
||||
content-hash = "3a8e8a7152971ae091864e7dd5a8fd25f895f68dd1444bffc153c61227e84914"
|
||||
|
||||
[metadata.files]
|
||||
appdirs = [
|
||||
@ -655,9 +660,7 @@ falcon = [
|
||||
{file = "falcon-2.0.0-py2.py3-none-any.whl", hash = "sha256:54f2cb4b687035b2a03206dbfc538055cc48b59a953187b0458aa1b574d47b53"},
|
||||
{file = "falcon-2.0.0.tar.gz", hash = "sha256:eea593cf466b9c126ce667f6d30503624ef24459f118c75594a69353b6c3d5fc"},
|
||||
]
|
||||
falcon-swagger-ui = [
|
||||
{file = "falcon_swagger_ui-1.2.1-py3-none-any.whl", hash = "sha256:2514e6cb403e87e49a1527764cf090c82885185cc650b7ab5cefa8ebe89af8b8"},
|
||||
]
|
||||
falcon-swagger-ui = []
|
||||
flake8 = [
|
||||
{file = "flake8-3.8.4-py2.py3-none-any.whl", hash = "sha256:749dbbd6bfd0cf1318af27bf97a14e28e5ff548ef8e5b1566ccfb25a11e7c839"},
|
||||
{file = "flake8-3.8.4.tar.gz", hash = "sha256:aadae8761ec651813c24be05c6f7b4680857ef6afaae4651a4eccaef97ce6c3b"},
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "dspace-statistics-api"
|
||||
version = "1.4.0-dev"
|
||||
version = "1.4.0"
|
||||
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"
|
||||
@ -11,7 +11,7 @@ gunicorn = "^20.0.4"
|
||||
falcon = "^2.0.0"
|
||||
psycopg2-binary = "^2.8.6"
|
||||
requests = "^2.24.0"
|
||||
falcon-swagger-ui = "^1.2.1"
|
||||
falcon-swagger-ui = {git = "https://github.com/alanorth/falcon-swagger-ui.git"}
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
ipython = { version = "^7.18.1", python = "^3.7" }
|
||||
|
@ -11,7 +11,7 @@ colorama==0.4.4; python_version >= "3.7" and python_version < "4.0" and sys_plat
|
||||
dataclasses==0.6; python_version < "3.7"
|
||||
decorator==4.4.2; python_version >= "3.7" and python_version < "4.0"
|
||||
falcon==2.0.0
|
||||
falcon-swagger-ui==1.2.1
|
||||
-e git+https://github.com/alanorth/falcon-swagger-ui.git@a44244c85dceccfcd249b62fea4ee82a8221e3d2#egg=falcon-swagger-ui
|
||||
flake8==3.8.4
|
||||
gunicorn==20.0.4
|
||||
idna==2.10
|
||||
|
@ -1,7 +1,7 @@
|
||||
certifi==2020.12.5
|
||||
chardet==4.0.0
|
||||
falcon==2.0.0
|
||||
falcon-swagger-ui==1.2.1
|
||||
-e git+https://github.com/alanorth/falcon-swagger-ui.git@a44244c85dceccfcd249b62fea4ee82a8221e3d2#egg=falcon-swagger-ui
|
||||
gunicorn==20.0.4
|
||||
idna==2.10
|
||||
jinja2==2.11.2
|
||||
|
Reference in New Issue
Block a user